npm ERR! code ERESOLVE
The npm ERR! code ERESOLVE error means npm found a peer dependency conflict. Fix it with --legacy-peer-deps, --force, or by updating conflicting packages.
What It Means
ERESOLVE is npm’s peer dependency resolution error, introduced in npm v7. When package A declares a peer dependency on a specific version of package B, and another package in your project requires a different (incompatible) version of B, npm refuses to proceed. The error message lists every conflicting package path.
Why It Happens
- Two packages in your project require different major versions of the same peer dependency.
- A package’s
peerDependenciesspecifies a range (e.g.,^17.0.0) but the installed version is outside that range. - Upgrading a framework (e.g., React 17 → 18) breaks peer dependency contracts for plugins still targeting the old version.
- Lockfile (
package-lock.json) is out of sync with the dependency tree.
How to Fix It
1. Use --legacy-peer-deps (quick workaround)
npm install --legacy-peer-depsThis tells npm to ignore peer dependency conflicts (reverting to npm v6 behavior). It’s a good temporary fix but may lead to runtime issues.
2. Use --force (alternate workaround)
npm install --forceThis forces npm to proceed, overwriting conflicting packages. Use only when --legacy-peer-deps doesn’t work.
3. Update the conflicting packages
Identify the exact conflict from the error output, then update the packages:
npm update react react-dom # update framework packages
npm install react-select@latest # update a plugin to a version compatible with your React version4. Check and dedupe the dependency tree
npm ls # view the full dependency tree
npm dedupe # deduplicate identical packages5. Clean install from scratch
rm -rf node_modules package-lock.json
npm installA fresh install often resolves resolution state corruption in the lockfile.
6. Use overrides (package.json)
Add an overrides field to your package.json to force a specific version:
{
"overrides": {
"react": "18.3.1"
}
}Then run npm install again.
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro