cli
cli copied to clipboard
[BUG] incorrect resolution of relative paths with install-strategy=linked
Is there an existing issue for this?
- [X] I have searched the existing issues
This issue exists in the latest npm version
- [X] I am using the latest npm
Current Behavior
I have a package with a relative path dependency.
File /Users/dan/Source/project1/package.json
{
"dependencies": {
"project2": "file:./project2"
}
}
And the file /Users/dan/Source/project1/project2/package.json exists.
This installs fine with every install strategy except linked where I receive the below error:
$ npm install --install-strategy linked
npm warn reify The "linked" install strategy is EXPERIMENTAL and may contain bugs.
npm warn tarball tarball data for project2@file:../project2 (null) seems to be corrupted. Trying again.
npm warn tarball tarball data for project2@file:../project2 (null) seems to be corrupted. Trying again.
npm error code ENOENT
npm error syscall open
npm error path /Users/dan/Source/project2/package.json
npm error errno -2
npm error enoent Could not read package.json: Error: ENOENT: no such file or directory, open '/Users/dan/Source/project2/package.json'
npm error enoent This is related to npm not being able to find a file.
npm error enoent
npm error A complete log of this run can be found in: /Users/dan/.npm/_logs/2024-05-22T02_17_21_083Z-debug-0.log
Note that:
- The error mentions
project2@file:../project2, which is not the depended path. - The path that it's looking for package.json is at
/Users/dan/Source/project2/package.json, NOT/Users/dan/Source/project1/project2/package.json
Expected Behavior
The package should install correctly.
Steps To Reproduce
see above
Environment
- npm: 10.8.0
- Node.js: 22.2.0
- OS Name: macOS
- System Model Name:
- npm config:
; copy and paste output from `npm config ls` here