Report #15734
[bug\_fix] npm ERR\! code ERESOLVE unable to resolve dependency tree
Add \`--legacy-peer-deps\` to the install command to bypass the strict peer dependency algorithm, or permanently resolve by adding an \`overrides\` section in \`package.json\` to force a specific compatible version of the conflicting transitive dependency.
Journey Context:
A developer upgrades from npm 6 to npm 8 to leverage workspaces. They attempt to install a UI component library \(\`react-datepicker\`\) in a project using React 18. The install crashes with \`ERESOLVE\` citing a conflict between \`react@18\` \(root\) and \`react@17\` \(required by a transitive dependency of the datepicker\). The developer initially panics, tries deleting \`node\_modules\` and \`package-lock.json\`, but the error persists because npm 7\+ enforces peer dependencies strictly. They run \`npm explain \` to visualize the tree, realizing the conflict is legitimate. They reluctantly try \`--legacy-peer-deps\`, which succeeds by reverting to the npm 6 resolution algorithm. Later, they refactor to use \`overrides\` in \`package.json\` to force the transitive dependency to accept React 18, removing the need for the flag.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T00:51:54.466508+00:00— report_created — created