Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
Running a global install of a package with a postinstall script prints:
npm warn allow-scripts 1 package has install scripts not yet covered by allowScripts:
npm warn allow-scripts @anthropic-ai/claude-code@2.1.159 (postinstall: node install.cjs)
npm warn allow-scripts Run `npm approve-scripts --allow-scripts-pending` to review, or `npm approve-scripts <pkg>` to allow.
Two problems with this in a global context:
- The suggested command doesn't apply.
npm approve-scripts manages the allowScripts field in a project package.json, and global installs have no project package.json. Internally, the package.json layer is skipped entirely when npm.global is true, so the suggested command has nothing to act on.
- It's not clear how (or whether) approved scripts can be managed globally at all. Every other npm setting can live in global/user config; it isn't obvious that install-script approvals can.
Expected Behavior
For global installs, the warning should either:
- point at whatever the actual global mechanism is (the
allow-scripts config / --allow-scripts flag, which are consulted for global installs), instead of approve-scripts --allow-scripts-pending, or
- omit the
approve-scripts suggestion when there's no project package.json to write to.
And the docs should state plainly whether global install-script approvals are supported, and how.
Steps To Reproduce
npm install -g @anthropic-ai/claude-code (or any package with an install/postinstall script).
- Observe the
allow-scripts warning suggesting npm approve-scripts --allow-scripts-pending.
- Run that command (there is no project package.json, so it cannot record the approval).
Environment
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
Running a global install of a package with a
postinstallscript prints:Two problems with this in a global context:
npm approve-scriptsmanages theallowScriptsfield in a project package.json, and global installs have no project package.json. Internally, the package.json layer is skipped entirely whennpm.globalis true, so the suggested command has nothing to act on.Expected Behavior
For global installs, the warning should either:
allow-scriptsconfig /--allow-scriptsflag, which are consulted for global installs), instead ofapprove-scripts --allow-scripts-pending, orapprove-scriptssuggestion when there's no project package.json to write to.And the docs should state plainly whether global install-script approvals are supported, and how.
Steps To Reproduce
npm install -g @anthropic-ai/claude-code(or any package with an install/postinstall script).allow-scriptswarning suggestingnpm approve-scripts --allow-scripts-pending.Environment