Report #38227
[bug\_fix] npm ERR\! ERESOLVE unable to resolve dependency tree
Run npm install with the --legacy-peer-deps flag to revert to npm 6.x behavior that does not automatically install peer dependencies, or manually add conflicting peer dependencies to overrides/resolutions in package.json.
Journey Context:
After upgrading from Node 14/npm 6 to Node 18/npm 8, running npm install on an existing React project suddenly fails with ERESOLVE. The error log shows that package A requires react@^17 while package B requires react@^18, and npm cannot resolve this. You try deleting node\_modules and package-lock.json, but the error persists. Checking the npm documentation reveals that npm 7\+ introduced automatic installation of peer dependencies by default, which creates impossible version constraints when different branches of the tree require incompatible peer versions. The --legacy-peer-deps flag disables this automatic installation, restoring the npm 6 behavior where peer dependencies were the host project's responsibility, allowing the install to proceed with warnings instead of hard errors.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T18:38:12.856909+00:00— report_created — created