fix: installLinks works with transitive external file dependencies#8534
Merged
owlstronaut merged 1 commit intolatestfrom Aug 27, 2025
Merged
fix: installLinks works with transitive external file dependencies#8534owlstronaut merged 1 commit intolatestfrom
owlstronaut merged 1 commit intolatestfrom
Conversation
e44d29f to
dcd4f8f
Compare
wraithgar
reviewed
Aug 27, 2025
dcd4f8f to
8e21bdf
Compare
wraithgar
approved these changes
Aug 27, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_FOUNDerrors.Why
When using
npm install --install-linksto install a local package that has its own file dependencies, npm would attempt to resolve the transitive dependencies relative to the installed location innode_modulesrather 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 ../bfrommainpkgwould fail because npm tried to find a relative tobinstead of relative to the originalbsource location.How
The fix introduces logic to detect transitive file dependencies when
--install-linksis 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-linksand 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