Report #86803
[bug\_fix] npm ERR\! could not resolve dependency: peer \[pkg\]@"^16.0.0" from \[pkg\]@version while we have \[pkg\]@17.0.0
Add --legacy-peer-deps to your npm install command to restore npm 6.x behavior where peer dependency version mismatches are warnings rather than installation-blocking errors. Alternatively, use overrides in package.json to force the specific version you need: "overrides": \{ "react": "$react" \} ensures all packages use the root version.
Journey Context:
You upgrade to Node.js 18 which ships with npm 8. You try to install a package that depends on React 16, but your project uses React 17. Instead of a warning, npm errors out with 'could not resolve dependency' and refuses to install anything. You try --force but worry it will break things. You check the npm changelog and discover that npm 7\+ automatically installs peer dependencies and treats version conflicts as hard errors, unlike npm 6 which ignored them. The rabbit hole involves understanding that this change was made to prevent 'dependency hell' where multiple copies of React would be installed silently, but it breaks legacy projects. The fix works because --legacy-peer-deps tells npm to skip the automatic peer dependency installation and conflict validation entirely, reverting to the lenient algorithm that allows the install to proceed with a warning, acknowledging that the user takes responsibility for ensuring compatibility.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T04:17:24.724739+00:00— report_created — created