Report #93422
[bug\_fix] npm ERR\! ERESOLVE could not resolve dependency tree due to conflicting peer dependencies
Run npm install with the --legacy-peer-deps flag to restore npm 6.x peer dependency resolution behavior, or manually align the conflicting peer dependency versions in package.json to satisfy the strict range requirements.
Journey Context:
Developer upgrades to Node 18/20 which bundles npm 7\+. Running npm install on an existing React project fails with ERESOLVE, complaining that react-dom@17 has unmet peer react@^17.0.0 but the tree contains react@18. The developer deletes node\_modules and package-lock.json repeatedly, but the error persists because npm 7\+ automatically installs peer dependencies and enforces strict tree validation. They dig into npm docs and find that npm 7 changed the peer dependency algorithm. Using --legacy-peer-deps tells npm to ignore peer dependency conflicts and install the tree as-is, matching the old hoisting behavior where peers were satisfied implicitly by the root project, unblocking the installation.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T15:23:42.212346+00:00— report_created — created