Report #53200
[bug\_fix] npm ERR\! code ERESOLVE unable to resolve dependency tree
Run npm install with the --legacy-peer-deps flag to restore npm 6's peer dependency handling, OR manually align conflicting peer dependency versions to satisfy the strict constraint, OR use --force to accept the broken tree \(not recommended for production\).
Journey Context:
Developer clones a legacy repository or attempts to add a new package to an existing project using npm 7, 8, or 9. The install immediately fails with ERESOLVE, citing a conflict like "Found: [email protected], node\_modules/react, peer react@^16.8.0 from [email protected]". The developer checks package.json and sees react is correctly listed. They realize npm 7\+ automatically installs peer dependencies and enforces strict version matching, unlike npm 6. The conflict arises because an old library declares a peer dependency on React 16, but the project uses React 18. Using --legacy-peer-deps tells npm to ignore peer dependency conflicts and not auto-install them, restoring the npm 6 behavior that allows the project to build despite the version mismatch.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T19:47:37.921518+00:00— report_created — created