Explore using npm install-strategy=linked#75814
Draft
manzoorwanijk wants to merge 4 commits intotrunkfrom
Draft
Conversation
3b0ea84 to
61ad5b1
Compare
15be57c to
4a29dff
Compare
2 tasks
owlstronaut
pushed a commit
to npm/cli
that referenced
this pull request
Feb 24, 2026
) Continuing the `install-strategy=linked` fixes from #8996. While testing on the [Gutenberg monorepo](WordPress/gutenberg#75814), `esbuild` installs fail because its postinstall script runs twice in parallel against the same store directory. ## Summary With `install-strategy=linked`, postinstall scripts run twice for every store package — once for the store entry and once for its symlink. For packages like `esbuild` whose postinstall modifies files in-place (`fs.linkSync` to replace the JS wrapper with a native binary), this race condition corrupts the install. ## Root cause In `rebuild.js`, `#runScripts` destructures `isStoreLink` from `node.target` (the store entry) to decide whether to skip a node. But `isStoreLink` is a property of the link node itself (`node`), not its target. Store entries don't have `isStoreLink`, so it's always `undefined` and the guard never triggers. Both the store entry and the store link run scripts against the same directory in parallel. ## Changes - Fixed the skip condition in `rebuild.js` `#runScripts` to use `node.isLink && node.target?.isInStore` instead of reading `isStoreLink` from `node.target`. This correctly skips store links (symlinks pointing to store entries) while still allowing workspace links and store entries themselves to run scripts. - Added a regression test that verifies postinstall scripts run exactly once for store packages. ## References Fixes #9012
manzoorwanijk
added a commit
to manzoorwanijk/npm-cli
that referenced
this pull request
Feb 25, 2026
…m#9013) Continuing the `install-strategy=linked` fixes from npm#8996. While testing on the [Gutenberg monorepo](WordPress/gutenberg#75814), `esbuild` installs fail because its postinstall script runs twice in parallel against the same store directory. ## Summary With `install-strategy=linked`, postinstall scripts run twice for every store package — once for the store entry and once for its symlink. For packages like `esbuild` whose postinstall modifies files in-place (`fs.linkSync` to replace the JS wrapper with a native binary), this race condition corrupts the install. ## Root cause In `rebuild.js`, `#runScripts` destructures `isStoreLink` from `node.target` (the store entry) to decide whether to skip a node. But `isStoreLink` is a property of the link node itself (`node`), not its target. Store entries don't have `isStoreLink`, so it's always `undefined` and the guard never triggers. Both the store entry and the store link run scripts against the same directory in parallel. ## Changes - Fixed the skip condition in `rebuild.js` `#runScripts` to use `node.isLink && node.target?.isInStore` instead of reading `isStoreLink` from `node.target`. This correctly skips store links (symlinks pointing to store entries) while still allowing workspace links and store entries themselves to run scripts. - Added a regression test that verifies postinstall scripts run exactly once for store packages. ## References Fixes npm#9012
This was referenced Feb 26, 2026
8fcbc89 to
28bd283
Compare
28bd283 to
bf53481
Compare
This was referenced Feb 27, 2026
bf53481 to
74902e8
Compare
aa3754b to
52f9569
Compare
14a9c65 to
a7840aa
Compare
This was referenced Mar 12, 2026
d1bcce6 to
047b9b1
Compare
This was referenced Mar 12, 2026
047b9b1 to
b9d0c56
Compare
b9d0c56 to
02536f6
Compare
3 tasks
|
Flaky tests detected in bfcccb4. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23453916034
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
#75213 didn't work well because it was resource-intensive due to duplicated node_modules packages. This PR tests npm-cli fixes from my fork
What?
Closes
Why?
How?
Testing Instructions
Testing Instructions for Keyboard
Screenshots or screencast