[BUG] unable to resolve dependency tree
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
Current Behavior:
Under certain conditions using npm pack on a dependency and later npm install xyz-1.2.3.tgz fails to install even when the same published package works when installed via registry.
See detailed steps to reproduce below but a short summary is:
@sandbox/basehave no dependencies (published as 1.0.0)@sandbox/pluginhave apeerDependency on@sandbox/base ^1` (published as 1.0.0)third-partyhave apeerDependencyon both@sandbox/base ^1and@sandbox/plugin ^1(published as 1.0.0)apphavedependencyon@sandbox/baseandthird-partyanddevDependencyon@sandbox/plugin
Installing using npm install works as expected but trying to install tarballs created with npm pack fails:
npm WARN tarball tarball data for @sandbox/plugin@file:../plugin/sandbox-plugin-1.0.0.tgz (null) seems to be corrupted. Trying again.
npm WARN tarball tarball data for @sandbox/plugin@file:../plugin/sandbox-plugin-1.0.0.tgz (null) seems to be corrupted. Trying again.
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-app@1.0.0
npm ERR! Found: @sandbox/plugin@undefined
npm ERR! node_modules/@sandbox/plugin
npm ERR! dev @sandbox/plugin@"file:../plugin/sandbox-plugin-1.0.0.tgz" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @sandbox/plugin@"^1" from third-party@1.0.0
npm ERR! node_modules/third-party
npm ERR! third-party@"file:../third-party/third-party-1.0.0.tgz" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /home/ext/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ext/.npm/_logs/2021-02-20T13_03_48_472Z-debug.log
Using --legacy-peer-deps works as expected.
Two things stand out:
"tarball data for @sandbox/plugin@file:../plugin/sandbox-plugin-1.0.0.tgz (null) seems to be corrupted. Trying again."
and
"Found: @sandbox/plugin@undefined"
The contens of eresolve-report.txt is the following:
# npm resolution error report
2021-02-20T13:42:00.931Z
While resolving: my-app@1.0.0
Found: @sandbox/plugin@undefined
node_modules/@sandbox/plugin
dev @sandbox/plugin@"file:../plugin/sandbox-plugin-1.0.0.tgz" from the root project
Could not resolve dependency:
peer @sandbox/plugin@"^1" from third-party@1.0.0
node_modules/third-party
third-party@"file:../third-party/third-party-1.0.0.tgz" from the root project
Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.
Raw JSON explanation object:
{
"code": "ERESOLVE",
"current": {
"name": "@sandbox/plugin",
"errors": [
{
"errno": -2,
"code": "ENOENT",
"syscall": "open",
"path": "/plugin/sandbox-plugin-1.0.0.tgz",
"requiredBy": "."
}
],
"package": {},
"whileInstalling": {
"name": "my-app",
"version": "1.0.0",
"path": "/home/ext/temp/npm-7-pack/app"
},
"location": "node_modules/@sandbox/plugin",
"dependents": [
{
"type": "dev",
"name": "@sandbox/plugin",
"spec": "file:../plugin/sandbox-plugin-1.0.0.tgz",
"error": "INVALID",
"from": {
"location": "/home/ext/temp/npm-7-pack/app"
}
}
]
},
"edge": {
"type": "peer",
"name": "@sandbox/plugin",
"spec": "^1",
"error": "INVALID",
"from": {
"name": "third-party",
"version": "1.0.0",
"whileInstalling": {
"name": "my-app",
"version": "1.0.0",
"path": "/home/ext/temp/npm-7-pack/app"
},
"location": "node_modules/third-party",
"dependents": [
{
"type": "prod",
"name": "third-party",
"spec": "file:../third-party/third-party-1.0.0.tgz",
"error": "INVALID",
"from": {
"location": "/home/ext/temp/npm-7-pack/app"
}
}
]
}
},
"peerConflict": null,
"strictPeerDeps": false,
"force": false
}
Expected Behavior:
No error.
Steps To Reproduce:
There is a github repository demonstrating the issue at https://github.com/ext/npm-7-pack-bug which is probably the simplest way to reproduce the issue. Following the instructions in README.md triggers the issue.
This is the simplest form I've reproduced this error but it might be possible to further reduce it.
Otherwise:
- Create package
@sandbox/baseat version1.0.0, publish to registry, create tarball withnpm pack - Create package
@sandbox/pluginat version1.0.0withpeerDependency on@sandbox/baseat^1, publish to registry, create tarball withnpm pack` - Create package
third-partyat version1.0.0withpeerDependencyon@sandbox/baseat^1and@sandbox/pluginat^1, publish to registry, create tarball withnpm pack - Create application
appwithdependencyon@sandbox/baseat1.0.0andthird-partyat1.0.0anddevDependencyon@sandbox/pluginat1.0.0. - Install dependencies with
npm install - Use
npm install sandbox-base-1.0.0.tgz sandbox-plugin-1.0.0.tgz third-party-1.0.0.tgz
Environment:
- OS: Ubuntu 20.20
- Node: 14.15.3
- NPM: 7.5.4
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the README.md and reproduction repository at github.com/ext/npm-7-pack-bug, then run the documented npm install commands using the packed tarballs. Compare the tarball and registry installation paths, focusing on the ERESOLVE report showing the package as undefined. Done means the tarball installation succeeds without --legacy-peer-deps while the registry case continues to work.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100