Draft
Conversation
3b0ea84 to
61ad5b1
Compare
61ad5b1 to
3c1d042
Compare
|
Size Change: -2.65 kB (-0.04%) Total Size: 6.84 MB
ℹ️ View Unchanged
|
4c3414d to
15be57c
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 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