fix(arborist): report ETARGET instead of ERESOLVE for unresolvable peer targets #10118

Merged
github-actions[bot] opened 11:57am on October 12, 2026 wanted to merge 1 commit into npm/cli release/v11 from
backport/v11/9987

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 latest source (c9876d7ea); also npm 10.9.2
  • Node.js: v24.18.0
  • OS Name: macOS Darwin 25.6.0
  • npm config: none required (min-release-age flattens to before)
github-actions[bot]
Diff Delta:
0
Classified as:  Bug Fix

github-actions[bot]'s Description of Work #9979 [BUG] Unresolvable dependency that is also a peer reports ERESOLVE `Found: <pkg>@undefined` instead of ETARGET

Backport of #9987 to release/v11.

0 total changed files
You are now leaving the Pull Request Diff Zone
The diff well is dry.