Report #20764
[bug\_fix] npm ERR\! code ERESOLVE npm ERR\! ERESOLVE could not resolve dependency tree
Add the --legacy-peer-deps flag to npm install to revert to the npm 6 peer dependency resolution algorithm that allows conflicts, or manually upgrade/downgrade packages to satisfy strict peer dependency ranges.
Journey Context:
Developer upgrades to Node 18 LTS which bundles npm 7\+. They clone a legacy React enterprise monorepo and run npm install. Instead of success, the terminal fills with red ERESOLVE errors citing peer dependency conflicts between react@17 and react@18 across transitive ESLint plugin dependencies. The developer repeatedly deletes node\_modules and package-lock.json, but the error persists because npm 7\+ treats peer dependency mismatches as hard installation blockers rather than warnings. They descend into npm ls hell, manually tracing the dependency tree, before discovering that npm 6's 'loose' peer dependency resolution simply ignored these conflicts. Adding --legacy-peer-deps to the install command restores the legacy algorithm, allowing installation to proceed with warnings instead of crashes, unblocking the developer immediately.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T13:15:34.218182+00:00— report_created — created