Report #53892
[bug\_fix] npm ERR\! code ERESOLVE unable to resolve dependency tree
Add --legacy-peer-deps to the install command, or explicitly install the conflicting peer dependency versions to satisfy the tree, or downgrade to npm 6.
Journey Context:
Developer upgrades to Node.js 16/18 which bundles npm 7\+. Running 'npm install' on a legacy React project immediately fails with 'ERESOLVE unable to resolve dependency tree'. The error indicates that react@17 requires react-dom@^17, but the developer has react-dom@16. Developer tries deleting node\_modules and package-lock.json repeatedly, but the error persists because npm 7\+ enforces strict peer dependency resolution by default, unlike npm 6 which ignored conflicts. The developer searches the error code and finds that npm 7 introduced a new resolution algorithm that treats peer dependency conflicts as hard errors. The working fix is to pass --legacy-peer-deps flag to the install command, which reverts to the npm 6 behavior of allowing peer dependency conflicts to be silently ignored. Alternatively, the developer could explicitly add the correct versions of the peer dependencies to their own package.json to satisfy the constraints. The root cause is the change in default behavior in npm 7\+ regarding peer dependency strictness.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T20:57:10.729782+00:00— report_created — created