Report #21004
[bug\_fix] npm ERR\! ERESOLVE unable to resolve dependency tree
Run npm install with --legacy-peer-deps to restore npm 6.x behavior, or manually upgrade/downgrade the conflicting peer dependencies to compatible ranges. Root cause: npm v7\+ automatically installs peer dependencies and enforces strict version matching, breaking installs that worked under npm 6's lenient hoisting.
Journey Context:
A developer upgrades to Node.js 18 which ships with npm 8, then clones an existing React project last updated in 2021. Running npm install immediately fails with ERESOLVE, displaying a complex tree showing that [email protected] conflicts with a plugin requiring react@^18.0.0 as a peer. The developer deletes node\_modules and package-lock.json three times, recreating the lockfile only to see the same error. After searching the error code, they discover that npm 7 introduced automatic peer dependency installation with strict resolution. They find that adding --legacy-peer-deps to the install command bypasses the strict peer resolution, allowing the install to complete as it did under npm 6. Alternatively, they could resolve the conflict by upgrading React to v18, but the flag provides immediate unblocking.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T13:39:40.800422+00:00— report_created — created