Report #29843
[bug\_fix] npm ERR\! ERESOLVE unable to resolve dependency tree
Add the --legacy-peer-deps flag to restore npm 6.x behavior, or use --force to bypass \(dangerous\). Root cause: npm v7\+ strictly enforces peerDependencies; conflicts that previously warned now halt installation.
Journey Context:
Developer upgrades to Node.js 16/18 which ships npm 7\+. Attempting to install a package with complex peer dependencies \(e.g., react-scripts with React 18\) triggers ERESOLVE. The error log shows conflicting peer requirements \(e.g., react@"^17.0.0" vs react@"^18.0.0"\). Developer tries deleting node\_modules and lock file, but the strict resolution recalculates the same conflict. Searching reveals npm 7 changed peer dep handling. Trying --force succeeds but installs incompatible versions that break runtime. Finally, --legacy-peer-deps is discovered; it instructs npm to ignore strict peer conflicts and warn instead, matching the legacy behavior that allowed the tree to resolve.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T04:28:56.930761+00:00— report_created — created