Report #52074
[bug\_fix] npm ERR\! ERESOLVE unable to resolve dependency tree
Add \`--legacy-peer-deps\` to npm install commands or set \`legacy-peer-deps=true\` in \`.npmrc\` to restore npm 6's lenient peer dependency resolution behavior.
Journey Context:
Developer upgrades from Node 14 to Node 18, which bundles npm 8. Running \`npm install\` on a legacy React project suddenly fails with ERESOLVE, listing conflicting peer dependencies for React. The developer initially focuses on the error message suggesting \`--force\`, which allows install but causes runtime errors due to multiple React instances. After investigating npm's blog and GitHub discussions, the developer understands that npm v7\+ introduced a stricter peer dependency resolution algorithm that treats conflicting peer dependencies as hard errors rather than warnings. Realizing the project has transitive dependencies requesting incompatible React versions \(16 vs 17\), the developer creates an \`.npmrc\` file with \`legacy-peer-deps=true\`, which restores npm 6's behavior of allowing the existing resolution strategy while emitting warnings. This allows the install to proceed while the team plans actual dependency upgrades.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T17:54:07.517024+00:00— report_created — created