Skip to content

fix(arborist): unwrap Link nodes in legacyPeerDeps for linked strategy#9051

Merged
owlstronaut merged 2 commits intonpm:latestfrom
manzoorwanijk:fix/linked-legacy-peer-deps-eexist
Mar 3, 2026
Merged

fix(arborist): unwrap Link nodes in legacyPeerDeps for linked strategy#9051
owlstronaut merged 2 commits intonpm:latestfrom
manzoorwanijk:fix/linked-legacy-peer-deps-eexist

Conversation

@manzoorwanijk
Copy link
Contributor

@manzoorwanijk manzoorwanijk commented Mar 3, 2026

When legacyPeerDeps is enabled and a workspace has a peer dependency on another workspace, node.resolve() in assignCommonProperties returns the Link node (at node_modules/<ws>) rather than its target (at packages/<ws>). The normal edge-based path correctly unwraps via e.to.target, but the legacyPeerDeps fallback pushed the raw resolved node directly.

This caused workspaceProxy to be called with the Link (a different object from the fsChild), creating a second workspace proxy with localLocation="node_modules/<ws>". Store links for that workspace's deps were then placed at node_modules/<ws>/node_modules/<dep> instead of packages/<ws>/node_modules/<dep>, racing with the workspace symlink at node_modules/<ws> and hitting EEXIST on subsequent installs.

Fix: use resolved.target to unwrap Link nodes, consistent with the edge-based path.

References

Fixes #9050

@manzoorwanijk manzoorwanijk requested a review from a team as a code owner March 3, 2026 11:16
@manzoorwanijk manzoorwanijk changed the title fix(arborist): unwrap Link nodes in legacyPeerDeps resolution for linked strategy fix(arborist): unwrap Link nodes in legacyPeerDeps for linked strategy Mar 3, 2026
@manzoorwanijk manzoorwanijk force-pushed the fix/linked-legacy-peer-deps-eexist branch from 859d037 to 6894d93 Compare March 3, 2026 11:32
@owlstronaut owlstronaut self-assigned this Mar 3, 2026
Copy link
Contributor

@owlstronaut owlstronaut left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix is good - already verified. we try to keep our codebase screen reader friendly when introducing new comments. Can approve and merge after

@owlstronaut owlstronaut merged commit 10d5302 into npm:latest Mar 3, 2026
16 checks passed
wraithgar pushed a commit that referenced this pull request Mar 4, 2026
This contains the changes from

- a2154cd (#8996)
- 880ecb7 (#9013)
- 26fa40e (#9041)
- 983742b (#9055)
- 10d5302 (#9051)
- a29aeee (#9028)
- 16fbe13 (#9030)
- 8614b2a (#9031)

Since Node 22 doesn't have npm 11 yet, it would be better to have this
change backported to v10


Also, we wish to use `install-strategy=linked` in the [Gutenberg
monorepo](WordPress/gutenberg#75814), which
powers the WordPress Block Editor. We are still on v10. So, these fixes
will help.
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] EEXIST on workspace symlinks with --install-strategy=linked and legacy-peer-deps

2 participants