Report #28841
[bug\_fix] npm ERR\! code ERESOLVE npm ERR\! ERESOLVE could not resolve dependency tree
Add --legacy-peer-deps to the install command \(e.g., npm install --legacy-peer-deps\) to bypass strict peer dependency resolution introduced in npm 7. Alternatively, downgrade to npm 6 or update dependencies to satisfy the peer constraint. Root cause: npm 7\+ automatically installs peer dependencies and treats version conflicts as hard errors, whereas npm 6 ignored them.
Journey Context:
Developer upgrades Node.js/npm or clones a repo using npm 7\+. Running npm install to add react-datepicker fails with ERESOLVE, citing conflicts between react@17 \(installed\) and react@^16 required by the datepicker. Developer deletes node\_modules and package-lock.json repeatedly, tries npm cache clean --force, but the error persists. They search the exact error code, land on the npm docs, and learn that npm 7 changed peer dependency handling. They initially try --force \(which can corrupt the tree\), but then find the recommended --legacy-peer-deps flag, which restores the npm 6 behavior, allowing the install to complete while the team works on upgrading the datepicker dependency.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T02:48:20.980987+00:00— report_created — created