Skip to content

Explore using npm install-strategy=linked#75814

Draft
manzoorwanijk wants to merge 4 commits intotrunkfrom
update/use-npm-install-strategy-linked
Draft

Explore using npm install-strategy=linked#75814
manzoorwanijk wants to merge 4 commits intotrunkfrom
update/use-npm-install-strategy-linked

Conversation

@manzoorwanijk
Copy link
Member

#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

Before After

@manzoorwanijk manzoorwanijk self-assigned this Feb 23, 2026
@github-actions github-actions bot added [Package] Core data /packages/core-data [Package] Components /packages/components [Package] Redux Routine /packages/redux-routine [Package] Notices /packages/notices [Package] Priority Queue /packages/priority-queue [Package] Theme /packages/theme labels Feb 23, 2026
@manzoorwanijk manzoorwanijk force-pushed the update/use-npm-install-strategy-linked branch 3 times, most recently from 3b0ea84 to 61ad5b1 Compare February 23, 2026 08:46
@manzoorwanijk manzoorwanijk force-pushed the update/use-npm-install-strategy-linked branch 4 times, most recently from 15be57c to 4a29dff Compare February 23, 2026 11:02
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
@manzoorwanijk manzoorwanijk force-pushed the update/use-npm-install-strategy-linked branch 2 times, most recently from 8fcbc89 to 28bd283 Compare February 26, 2026 10:08
@WordPress WordPress deleted a comment from github-actions bot Feb 26, 2026
@manzoorwanijk manzoorwanijk force-pushed the update/use-npm-install-strategy-linked branch from 28bd283 to bf53481 Compare February 27, 2026 05:17
@manzoorwanijk manzoorwanijk force-pushed the update/use-npm-install-strategy-linked branch from bf53481 to 74902e8 Compare March 3, 2026 07:18
@manzoorwanijk manzoorwanijk force-pushed the update/use-npm-install-strategy-linked branch from aa3754b to 52f9569 Compare March 12, 2026 12:44
@WordPress WordPress deleted a comment from github-actions bot Mar 12, 2026
@manzoorwanijk manzoorwanijk force-pushed the update/use-npm-install-strategy-linked branch 3 times, most recently from 14a9c65 to a7840aa Compare March 12, 2026 13:53
@WordPress WordPress deleted a comment from github-actions bot Mar 12, 2026
@WordPress WordPress deleted a comment from github-actions bot Mar 12, 2026
@manzoorwanijk manzoorwanijk force-pushed the update/use-npm-install-strategy-linked branch 3 times, most recently from d1bcce6 to 047b9b1 Compare March 12, 2026 18:00
@WordPress WordPress deleted a comment from github-actions bot Mar 12, 2026
@manzoorwanijk manzoorwanijk force-pushed the update/use-npm-install-strategy-linked branch from 047b9b1 to b9d0c56 Compare March 12, 2026 20:03
@github-actions github-actions bot added [Package] E2E Tests /packages/e2e-tests [Package] Project management automation /packages/project-management-automation [Package] UI /packages/ui [Package] Sync and removed [Package] Core data /packages/core-data labels Mar 12, 2026
@WordPress WordPress deleted a comment from github-actions bot Mar 12, 2026
@WordPress WordPress deleted a comment from github-actions bot Mar 12, 2026
@manzoorwanijk manzoorwanijk force-pushed the update/use-npm-install-strategy-linked branch from b9d0c56 to 02536f6 Compare March 12, 2026 20:23
@github-actions
Copy link

Flaky tests detected in bfcccb4.
Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/23453916034
📝 Reported issues:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Package] Block editor /packages/block-editor [Package] Block library /packages/block-library [Package] Components /packages/components [Package] E2E Tests /packages/e2e-tests [Package] Notices /packages/notices [Package] Priority Queue /packages/priority-queue [Package] Project management automation /packages/project-management-automation [Package] Redux Routine /packages/redux-routine [Package] Sync [Package] Theme /packages/theme [Package] UI /packages/ui

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants