Skip to content

unable to publish to s3 - Cannot read property 'slice' of undefined #571

@adnan-kamili

Description

@adnan-kamili

I recently upgraded to the latest verision 1.x from 0.x. Since then unpublish command is crashing

node-pre-gyp ERR! UNCAUGHT EXCEPTION 
node-pre-gyp ERR! stack TypeError: Cannot read property 'slice' of undefined
node-pre-gyp ERR! stack     at Object.module.exports.detect (/home/runner/work/lexactivator-js/lexactivator-js/node_modules/@mapbox/node-pre-gyp/lib/util/s3_setup.js:21:29)
node-pre-gyp ERR! stack     at unpublish (/home/runner/work/lexactivator-js/lexactivator-js/node_modules/@mapbox/node-pre-gyp/lib/unpublish.js:18:12)
node-pre-gyp ERR! stack     at Object.self.commands.<computed> [as unpublish] (/home/runner/work/lexactivator-js/lexactivator-js/node_modules/@mapbox/node-pre-gyp/lib/node-pre-gyp.js:81:37)
node-pre-gyp ERR! stack     at run (/home/runner/work/lexactivator-js/lexactivator-js/node_modules/@mapbox/node-pre-gyp/lib/main.js:81:30)
node-pre-gyp ERR! stack     at processTicksAndRejections (internal/process/task_queues.js:79:11)
node-pre-gyp ERR! System Linux 4.15.0-1108-azure
node-pre-gyp ERR! command "/opt/hostedtoolcache/node/12.21.0/x64/bin/node" "/home/runner/work/lexactivator-js/lexactivator-js/node_modules/.bin/node-pre-gyp" "package" "unpublish" "publish" "info"

I debugged and in your code it crashes at:

if (!config.region) {
    const region = parts[1].slice(1).split('.')[0]; // this line causes the crash
    if (region === 'amazonaws') {
      config.region = 'us-east-1';
    } else {
      config.region = region;
    }
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions