[BUG] Unresolvable dependency that is also a peer reports ERESOLVE `Found: <pkg>@undefined` instead of ETARGET
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 10.1k
- Forks
- 4.7k
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 19
Description
Is there an existing issue for this?
- I have searched the existing issues
This issue exists in the latest npm version
- I am using the latest npm
This is not just a request to bump a dependency for a CVE
- This is not solely a request to bump a dependency for a CVE
Current Behavior
When a root dependency has no matching version (e.g. every match is younger than min-release-age/before, or the range does not exist) and another dependency peers on it, npm fails with ERESOLVE ... Found: react@undefined. The real ETARGET is never shown, so users chase a nonexistent peer conflict. Seen in a large monorepo with min-release-age=1 and a freshly published webpack.
Expected Behavior
ETARGET No matching version found for react@^18.3.0 with a date before ..., as npm prints without the peer dependent or with --legacy-peer-deps.
Steps To Reproduce
mkdir x && cd x
printf '{"name":"x","version":"1.0.0","dependencies":{"react":"^18.3.0","react-dom":"18.2.0"}}' > package.json
npm install --package-lock-only --before=2024-01-01 # expected: ETARGET; actual: ERESOLVE Found: react@undefined
npm install --package-lock-only --before=2024-01-01 --legacy-peer-deps # ETARGET (correct)
npm pkg set dependencies.react=^99.0.0
npm install --package-lock-only # expected: ETARGET; actual: ERESOLVE Found: react@undefined
Environment
- npm: 12.0.2 and
latestsource (c9876d7ea); also npm 10.9.2 - Node.js: v24.18.0
- OS Name: macOS Darwin 25.6.0
- npm config: none required (
min-release-ageflattens tobefore)
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
Run the three npm install --package-lock-only reproductions in the issue and compare normal resolution with --legacy-peer-deps. Trace the dependency-resolution path that handles an unresolvable root dependency with a peer dependent; done means the normal commands report ETARGET with the missing package and range instead of ERESOLVE with package@undefined.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, nodejs
- Domain
- cli, devtools
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100