This work implements [BUG] Unresolvable dependency that is also a peer reports ERESOLVE `Found: <pkg>@undefined` instead of ETARGET (closed)
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
This is not just a request to bump a dependency for a CVE
- [x] 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)
You are now leaving the Pull Request Diff Zone
The diff well is dry.