Report #12733
[bug\_fix] npm ERR\! ERESOLVE unable to resolve dependency tree
Add the --legacy-peer-deps flag to the npm install command to restore npm 6 behavior, or explicitly install the conflicting peer dependency versions to satisfy all ranges in the tree.
Journey Context:
The developer upgrades from npm 6 to npm 7 or later, or clones a legacy project, and runs npm install. The command fails immediately with ERESOLVE, indicating that the dependency tree cannot be resolved because npm 7\+ strictly enforces peerDependencies by default, automatically installing them and validating that all peer dependency ranges are satisfied by a single version in the tree. The developer tries deleting node\_modules and package-lock.json, then reinstalling, but the error persists because the peer conflict is fundamental. They try --force, which bypasses the check but creates an invalid tree that crashes at runtime. The debugging rabbit hole involves running npm ls to see which packages declare conflicting peer ranges \(e.g., one package requires react@^17 while another requires react@^18\). The fix works because --legacy-peer-deps restores the npm 6 behavior where peer dependencies were not automatically installed or strictly validated during resolution, allowing the installation to proceed despite the version mismatch, giving the developer time to properly align the peer dependency ranges in the long term.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T16:48:04.655749+00:00— report_created — created