npm default install command always runs if binding.gyp exists, and package install script is ignored
Problem
Is there an existing issue for this? - [X] I have searched the existing issues This issue exists in the latest npm version - [X] I am using the latest npm Current Behavior 1. use npm 7 or 8 2. package.json contains install script 3. project root directory contains binding.gyp 4. npm install results in default npm install command `node-gyp rebuild` running instead of the install script in package.json It works correctly with npm 6. Expected Behavior Expect it to behave as documented: > If there is a binding.gyp file in the root of your package and you haven't defined your own install or preinstall scripts, npm will default the install command to compile using node-gyp via node-gyp rebuild I assume this means: > If there is a binding.gyp file in the root of your package and you have defined your own install or preinstall scripts, npm will run your install and preinstall scripts and not default the install command to compile using node-gyp via node-gyp rebuild Steps To Reproduce 1. Create new directory with new package.json that has no dependencies 2. See canvas has binding.gyp and an install script in package.json. 3. npm i canvas@latest -S --verbose 4. "install": "node-pre-gyp install --fallback-to-build --update-binary", in canvas package.json is NOt run but should be 5. `npm info run canvas@2.9.3 install node_modules/canvas node-gyp rebuild` is run but should NOT be 6. Behaves the same if canvas is added as a dependency in package.json and run `npm install` [code
Error Output
Error: command failed
Unverified for your environment
Select your OS to check compatibility.
1 Fix
Solution: npm default install command always runs if binding.gyp exists, and package install script is ignored
We have a very similar issue currently. Our builds started failing after this change to dd-native-metrics: https://github.com/DataDog/dd-native-metrics-js/pull/21 Here's a list of things that are the same or similar as in your case: - `node-gyp rebuild` gets run when installing this package and we don't understand why - Works with npm 6 - Does not work with npm 8 - We are using a private npm reg
Trust Score
3 verifications
- 1
We have a very similar issue currently. Our builds started failing after this ch
We have a very similar issue currently. Our builds started failing after this change to dd-native-metrics: https://github.com/DataDog/dd-native-metrics-js/pull/21
- 2
Here's a list of things that are the same or similar as in your case:
Here's a list of things that are the same or similar as in your case:
- 3
`node-gyp rebuild` gets run when installing this package and we don't understand
- Works with npm 6 - Does not work with npm 8 - We are using a private npm registry w/ Artifactory. The issue does _not_ occur when installing from the public npm registry.
- 4
Here's a list of things that are dissimilar:
Here's a list of things that are dissimilar:
Validation
Resolved in npm/cli GitHub issue #5234. Community reactions: 2 upvotes.
Verification Summary
Sign in to verify this fix
Environment
Submitted by
Alex Chen
2450 rep