Skip to content

fix(arborist): handle npm link with install-strategy=linked#9167

Open
manzoorwanijk wants to merge 1 commit intonpm:latestfrom
manzoorwanijk:fix/npm-link-linked-strategy
Open

fix(arborist): handle npm link with install-strategy=linked#9167
manzoorwanijk wants to merge 1 commit intonpm:latestfrom
manzoorwanijk:fix/npm-link-linked-strategy

Conversation

@manzoorwanijk
Copy link
Copy Markdown
Contributor

In continuation of our exploration of using install-strategy=linked in the Gutenberg monorepo, which powers the WordPress Block Editor.

npm link is completely broken with install-strategy=linked.
Both npm link <path> and npm link <pkg> (via global) crash with ENOENT because the isolated reifier tries to extract the linked package into .store/ instead of symlinking it.

The root cause is that npm link creates a file: dependency pointing outside the project root.
The Link node ends up in idealTree.children (not fsChildren) because its path is root/node_modules/<name>.
The isolated reifier doesn't recognize it as a local dependency, so it routes it through #externalProxy which tries to extract it into the store.
The file: relative path then gets resolved from the store entry location instead of the project root, producing a wrong absolute path.

The fix detects Link nodes with file: resolved paths and treats them as workspace-like local dependencies.
Instead of extracting into .store/, they get symlinked directly in node_modules/, matching the behavior of the hoisted strategy.

References

Fixes #9166

@manzoorwanijk manzoorwanijk requested a review from a team as a code owner March 30, 2026 20:11
@manzoorwanijk manzoorwanijk force-pushed the fix/npm-link-linked-strategy branch from 6d9bdb8 to 3f0b5f8 Compare March 30, 2026 20:16
@manzoorwanijk
Copy link
Copy Markdown
Contributor Author

@wraithgar I am not sure why CI fails with npm error Cannot find module 'promise-retry'

@owlstronaut
Copy link
Copy Markdown
Contributor

@wraithgar I am not sure why CI fails with npm error Cannot find module 'promise-retry'

don't worry about that, it is unrelated: nodejs/node#62425

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] npm link is broken with install-strategy=linked

2 participants