[BUG] Incomplete remediate prompt `npm install -g --allow-scripts=<package>`
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
Is there an existing issue for this?
- I have searched the existing issues
This issue exists in the latest npm version
- I am using the latest npm
This is not just a request to bump a dependency for a CVE
- This is not solely a request to bump a dependency for a CVE
Current Behavior
npm 12.0.2 prompts with "Run npm install -g --allow-scripts=<package> to allow these scripts once" which does not work.
$ npm install -g esbuild
added 2 packages in 3s
npm warn install-scripts 1 package had install scripts blocked because they are not covered by allowScripts:
npm warn install-scripts esbuild@0.28.1 (postinstall: node install.js)
npm warn install-scripts
npm warn install-scripts Run `npm install -g --allow-scripts=esbuild` to allow these scripts once, or `npm config set allow-scripts=esbuild --location=user` to allow them for all global installs.
$ npm install -g --allow-scripts=esbuild
npm error code ENOENT
npm error syscall open
npm error path /tmp/tmp.j1pwe1SPOy/package.json
npm error errno -2
npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open '/tmp/tmp.j1pwe1SPOy/package.json'
npm error enoent This is related to npm not being able to find a file.
npm error enoent
The second option npm config set allow-scripts=esbuild --location=user does however work as described.
Expected Behavior
The prompt should provide instructions that work, and possibly it should be changed to start with:
Run npm install -g <package> --allow-scripts=<package>
Steps To Reproduce
Execute the following:
cd $(mktemp -d)
npm install -g esbuild
Environment
- npm: 12.0.2
- Node.js: 26.5.1
- OS Name: Ubuntu 26.04.4 LTS
- System Model Name: HP x64 desktop
- npm config:
; node bin location = /home/mike/n/bin/node
; node version = v26.5.1
; npm local prefix = /tmp/tmp.j1pwe1SPOy
; npm version = 12.0.2
; cwd = /tmp/tmp.j1pwe1SPOy
; HOME = /home/mike
; Run `npm config ls -l` to show all defaults.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the npm install -g esbuild entry point in a temporary directory and trace where the install-scripts warning assembles its suggested command. Verify that the revised prompt works for a global install without the reported package.json ENOENT error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 74/100