Report #25435
[bug\_fix] npm ERR\! code ERESOLVE unable to resolve dependency tree
Add --legacy-peer-deps to npm install to restore npm 6.x behavior where peer dependency conflicts only warn instead of failing the install.
Journey Context:
Developer upgrades to Node 18/20 and npm 9. Running npm install on an existing project suddenly throws ERESOLVE with 'Could not resolve dependency' and 'Conflicting peer dependency'. The error tree shows React 17 vs 18 conflicts. Developer tries deleting node\_modules and package-lock.json, but the error persists. Research reveals npm 7\+ automatically installs peer dependencies and treats conflicts as hard errors. The developer finds that passing --legacy-peer-deps bypasses the strict peer dependency resolution, allowing the install to complete with warnings only, matching the behavior from npm 6. Alternatively, using --force ignores all peer dependency conflicts, but legacy-peer-deps is safer for existing projects.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T21:05:47.031350+00:00— report_created — created