Skip to content

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

Merged
owlstronaut merged 1 commit intonpm:latestfrom
manzoorwanijk:fix/npm-link-linked-strategy
Apr 17, 2026
Merged

fix(arborist): handle npm link with install-strategy=linked#9167
owlstronaut merged 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

@manzoorwanijk manzoorwanijk force-pushed the fix/npm-link-linked-strategy branch from 3f0b5f8 to 9e74d1b Compare April 17, 2026 08:50
@manzoorwanijk
Copy link
Copy Markdown
Contributor Author

CI seems to be happy now

@owlstronaut owlstronaut merged commit 0dc5585 into npm:latest Apr 17, 2026
18 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🎉 Backport to release/v11 created: #9253

@manzoorwanijk manzoorwanijk deleted the fix/npm-link-linked-strategy branch April 17, 2026 15:16
@manzoorwanijk
Copy link
Copy Markdown
Contributor Author

🎉 Backport to release/v11 created: #9253

Nice! Now we don’t need to do backports manually 👍

@wraithgar
Copy link
Copy Markdown
Member

Backports are only for v11 since we're in prerelease mode for v12. v10 likely only going to get critical updates now.

@manzoorwanijk
Copy link
Copy Markdown
Contributor Author

Backports are only for v11 since we're in prerelease mode for v12. v10 likely only going to get critical updates now.

Yes, makes sense. Thanks

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

3 participants