Skip to content

[BUG] Unreviewed-scripts warning suggests npm approve-scripts during global installs, where it can't work #9457

@JamieMagee

Description

@JamieMagee

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

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:

  1. 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.
  2. 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

  1. npm install -g @anthropic-ai/claude-code (or any package with an install/postinstall script).
  2. Observe the allow-scripts warning suggesting npm approve-scripts --allow-scripts-pending.
  3. Run that command (there is no project package.json, so it cannot record the approval).

Environment

  • npm: 11.16.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    Bugthing that needs fixingNeeds Triageneeds review for next steps

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions