You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: installLinks works with transitive external file dependencies (#8534)
fixes#8342
What
This PR fixes an issue where npm fails to properly handle transitive
file dependencies when using the --install-links flag. Previously, when
a file dependency had its own file dependencies, npm would fail to
resolve them correctly, resulting in `ERR_MODULE_NOT_FOUND` errors.
Why
When using `npm install --install-links` to install a local package that
has its own file dependencies, npm would attempt to resolve the
transitive dependencies relative to the installed location in
`node_modules` rather than the original source location. This caused the
installation to fail because the transitive dependencies couldn't be
found at the incorrect path.
For example, given this structure:
Running `npm install --install-links ../b` from `mainpkg` would fail
because npm tried to find a relative to `b` instead of relative to the
original `b` source location.
How
The fix introduces logic to detect transitive file dependencies when
`--install-links` is used and ensures they are resolved relative to
their parent's original source location:
Detect transitive file dependencies: When a parent package was installed
(not linked) due to `--install-links` and has file dependencies of its
own, those are identified as transitive file dependencies.
Preserve original paths: The parent's resolved` field (e.g., file:../b)
is used to determine the original source location.
Correct path resolution: Transitive file dependencies are resolved
relative to the parent's original location rather than its installed
location in `node_modules`
// if the spec matches a workspace name, then see if the workspace node will
1248
-
// satisfy the edge. if it does, we return the workspace node to make sure it
1249
-
// takes priority.
1253
+
// if the spec matches a workspace name, then see if the workspace node will satisfy the edge. if it does, we return the workspace node to make sure it takes priority.
0 commit comments