Skip to content

npm registry reports erroneous install script for emnapi package v1.0.0+ #112

@lovell

Description

@lovell

Hi Toyo, thanks for all your work on this tool.

As of 1.0.0, the npm registry is reporting that the emnapi package has an install script:

$ npm view --json emnapi scripts
{
  "build": "node ./script/build.js",
  "version": "node ./script/version.js",
  "install": "node-gyp rebuild"
}

This causes a problem from npm v10.5.0 (Node.js 20.12.0) onwards as it starts to respect this field.

npm v10.2.4 works:

$ nvm use 20.11.1
Now using node v20.11.1 (npm v10.2.4)

$ npm i emnapi
added 1 package, and audited 2 packages in 1s

npm v10.5.0 does not work:

$ nvm use 20.12.0
Now using node v20.12.0 (npm v10.5.0)

$ npm i emnapi
npm ERR! code 1
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@10.0.1
npm ERR! gyp info using node@20.12.0 | linux | x64
...
npm ERR! gyp: binding.gyp not found (cwd: /tmp/node_modules/emnapi) while trying to load binding.gyp
npm ERR! gyp ERR! configure error 
...
npm ERR! gyp ERR! node -v v20.12.0
npm ERR! gyp ERR! node-gyp -v v10.0.1
npm ERR! gyp ERR! not ok

There is no mention of an install script in the source package.json file:

"scripts": {
"build": "node ./script/build.js",
"version": "node ./script/version.js"
},

My best guess of the cause is that there might have been an extra (i.e. not under version control) packages/emnapi/binding.gyp file at the point in time at which npm publish was run, which the npm CLI tooling interpreted as the package requiring an install script, thanks to the @npmcli/node-gyp logic.

Are you able to check to see if this might have been the case, and if so, publish a new version without the binding.gyp file to see if the npm registry will remove the install script? Alternatively, you might need to declare a no-op install script to avoid the default value.

(A similar problem affected the @parcel/watcher package - see parcel-bundler/watcher#156 (comment))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions