Is there an existing issue for this?
This issue exists in the latest npm version
This is not just a request to bump a dependency for a CVE
Current Behavior
Trying to lock down my projects/CI pipelines and only run scripts when they are in allowScripts, block all others. NPM highlighted three dependencies that needed whitelisting:
$ npm approve-scripts --allow-scripts-pending
3 packages have install scripts not yet covered by allowScripts:
@swc/core@1.3.100 (postinstall: node postinstall.js)
protobufjs@7.5.4 (postinstall: node scripts/postinstall)
sharp@0.34.5 (install: node install/check.js || npm run build)
These were whitelisted and appear in my package.json file as expected. However, after clearing node_modules, setting strict-allow-scripts globally and attempting an npm ci run to test, I got this error:
$ npm ci
npm error code ESTRICTALLOWSCRIPTS
npm error --strict-allow-scripts: 1 package(s) have install scripts not covered by allowScripts:
npm error fsevents@2.3.3 (install: (install scripts present))
npm error Approve them with `npm approve-scripts`, deny them with `npm deny-scripts`, or bypass this check with `--dangerously-allow-all-scripts`.
fsevents package does not appear in the review list, with or without strict-allow-scripts switched on, but it clearly shows as having a script in my package-lock.json file:
"node_modules/fsevents": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.3.tgz",
"integrity": "sha512-5xoDfX+fL7faATnagmWPpbFtwh/R77WmMMqqHGS65C3vvB0YHrgF+B1YmZ3441tMj5n63k0212XNoJwzlhffQw==",
"dev": true,
"hasInstallScript": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
}
I have a feeling this has to do with this being an optional dependency. One command tells me it does not need to be whitelisted, another command tells me I cannot install dependencies unless it is whitelisted. This may not necessarily be a bug but it's certainly unclear messaging.
Expected Behavior
The npm approve-scripts --allow-scripts-pending command should list all packages that npm ci --strict-allow-scripts will reject when not allowed.
Steps To Reproduce
- Initialise an empty Next.JS project (should give the dependencies required for the test).
- Run
npm approve-scripts --allow-scripts-pending in the project folder and observe the three packages reported as having scripts.
- Add
@swc/core, protobufjs and sharp to allowScripts using npm approve-scripts.
- Turn on
strict-allow-scripts globally: npm config set --global strict-allow-scripts true.
- Delete the
node_modules folder.
- Run
npm ci in the project folder.
- See error described above.
Environment
Kubuntu 26.04, amd64
; "global" config from /home/silver/.nvm/versions/node/v24.16.0/etc/npmrc
min-release-age = 1
save-exact = true
save-prefix = ""
strict-allow-scripts = false
; "user" config from /home/silver/.npmrc
; node bin location = /home/silver/.nvm/versions/node/v24.16.0/bin/node
; node version = v24.16.0
; npm local prefix =
; npm version = 11.17.0
; cwd =
; HOME = /home/silver
; Run npm config ls -l to show all defaults.
Is there an existing issue for this?
This issue exists in the latest npm version
This is not just a request to bump a dependency for a CVE
Current Behavior
Trying to lock down my projects/CI pipelines and only run scripts when they are in
allowScripts, block all others. NPM highlighted three dependencies that needed whitelisting:These were whitelisted and appear in my
package.jsonfile as expected. However, after clearingnode_modules, settingstrict-allow-scriptsglobally and attempting annpm cirun to test, I got this error:fseventspackage does not appear in the review list, with or withoutstrict-allow-scriptsswitched on, but it clearly shows as having a script in mypackage-lock.jsonfile:I have a feeling this has to do with this being an optional dependency. One command tells me it does not need to be whitelisted, another command tells me I cannot install dependencies unless it is whitelisted. This may not necessarily be a bug but it's certainly unclear messaging.
Expected Behavior
The
npm approve-scripts --allow-scripts-pendingcommand should list all packages thatnpm ci --strict-allow-scriptswill reject when not allowed.Steps To Reproduce
npm approve-scripts --allow-scripts-pendingin the project folder and observe the three packages reported as having scripts.@swc/core,protobufjsandsharptoallowScriptsusingnpm approve-scripts.strict-allow-scriptsglobally:npm config set --global strict-allow-scripts true.node_modulesfolder.npm ciin the project folder.Environment
Kubuntu 26.04, amd64
; "global" config from /home/silver/.nvm/versions/node/v24.16.0/etc/npmrc
min-release-age = 1
save-exact = true
save-prefix = ""
strict-allow-scripts = false
; "user" config from /home/silver/.npmrc
; node bin location = /home/silver/.nvm/versions/node/v24.16.0/bin/node
; node version = v24.16.0
; npm local prefix =
; npm version = 11.17.0
; cwd =
; HOME = /home/silver
; Run
npm config ls -lto show all defaults.