npm / npm/cli

[BUG] Workspace lifecycle scripts silently skipped under `install-strategy=linked`

Open
#9,982 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Bug Needs Triage
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

With install-strategy=linked, npm install does not run a workspace's preinstall, install, postinstall or prepare scripts. Nothing is logged, the unreviewed scripts advisory does not list the workspace, and --strict-allow-scripts still exits 0. Hoisted on npm 12 and linked on npm 11.19.1 run all four.

Expected Behavior

Workspace scripts run under linked, as they do under hoisted, since workspaces are exempt from the allowScripts gate.

Steps To Reproduce
mkdir x && cd x
mkdir -p packages/a
echo '{"name":"r","version":"1.0.0","workspaces":["packages/*"]}' > package.json
echo '{"name":"a","version":"1.0.0","scripts":{"postinstall":"touch post.txt","prepare":"touch prepared.txt"}}' > packages/a/package.json
npm install --install-strategy=linked --no-audit --no-fund
ls packages/a   # expected: package.json post.txt prepared.txt, actual: package.json
Environment
  • npm: 12.0.2 and latest (c9876d7ea)
  • Node.js: v24.18.0
  • OS Name: macOS Darwin 25.6.0

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked-strategy reproduction using the root package.json and packages/a/package.json, then trace how npm install handles workspace lifecycle scripts. Done means preinstall, install, postinstall, and prepare run under install-strategy=linked, with the scripts visible in output and strict-allow-scripts behaving consistently with the expected workspace exemption.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Clearly specified
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.