Skip to content
npm ERR! code ERESOLVE

npm ERR! code ERESOLVE

DodaTech 2 min read

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 peerDependencies specifies 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-deps

This 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 --force

This 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 version

4. Check and dedupe the dependency tree

npm ls                            # view the full dependency tree
npm dedupe                        # deduplicate identical packages

5. Clean install from scratch

rm -rf node_modules package-lock.json
npm install

A 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.

Is --legacy-peer-deps safe for production?
It depends. If the peer dependency difference is minor (e.g., React 18.2 vs 18.3), it’s usually safe. But if two packages depend on incompatible major versions (e.g., React 17 vs 18), runtime errors are likely. Always prefer updating packages over using --legacy-peer-deps for production.
Why did ERESOLVE appear after upgrading npm?
npm v6 and earlier printed peer dependency conflicts as warnings and proceeded. npm v7+ changed this to a hard error. If you recently upgraded npm (from v6 to v7+), existing projects may show ERESOLVE for pre-existing conflicts that were previously hidden. The fix is the same — update the conflicting packages or use --legacy-peer-deps.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro