Skip to content

fix: resolve relative file: dependencies correctly with install-strategy=linked#9030

Open
manzoorwanijk wants to merge 1 commit intonpm:latestfrom
manzoorwanijk:fix/linked-strategy-relative-file-deps
Open

fix: resolve relative file: dependencies correctly with install-strategy=linked#9030
manzoorwanijk wants to merge 1 commit intonpm:latestfrom
manzoorwanijk:fix/linked-strategy-relative-file-deps

Conversation

@manzoorwanijk
Copy link
Contributor

@manzoorwanijk manzoorwanijk commented Feb 26, 2026

In continuation of our exploration of using install-strategy=linked in the Gutenberg monorepo, which powers the WordPress Block Editor, this is a follow up of the fixes from #8996.

When using install-strategy=linked, relative file: dependencies (e.g., file:./project2) fail with ENOENT because the path is resolved one level above the project root. For example, file:./project2 becomes file:../project2, causing npm to look for /Users/dan/Source/project2 instead of /Users/dan/Source/project1/project2.

In the isolated reifier, non-workspace file: dependencies are incorrectly classified as "external" dependencies. This routes them through the store extraction path (pacote.extract) instead of symlinking them directly like workspaces. A Link node's resolved value is relative to its node_modules/ location — that relative path becomes invalid when used from the store context.

This PR treats local file: dep targets found in fsChildren as local dependencies (alongside workspaces) so they get symlinked directly instead of extracted into the store:

  • _makeIdealGraph: Skip nodes from root.external if they (or their Link target) are in idealTree.fsChildren.
  • assignCommonProperties: Classify deps whose targets are in node.fsChildren as local dependencies instead of external.

References

Fixes #7549

…tegy

Local file: dependencies were incorrectly classified as external in the
isolated reifier, routing them through store extraction instead of
symlinking directly. This caused the relative path to resolve from the
wrong directory, producing ENOENT errors.

Treat file dep targets found in fsChildren as local dependencies,
alongside workspaces, so they get symlinked directly.
@manzoorwanijk manzoorwanijk requested a review from a team as a code owner February 26, 2026 06:17
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] incorrect resolution of relative paths with install-strategy=linked

1 participant