Skip to main content

npm · 5 common causes

npm ERESOLVE peer dependency conflict

Updated

npm refuses to install because two packages demand incompatible versions of the same peer dependency.

The exact message

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: my-app@1.0.0
npm ERR! Found: react@19.0.0
npm ERR! node_modules/react
npm ERR!   react@"^19.0.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^18.0.0" from some-ui-kit@3.2.1
npm ERR! node_modules/some-ui-kit

Paths, line numbers and stack frames differ on every machine, and the wording is tightened between versions. The part that identifies the problem is npm ERESOLVE peer dependency conflict.

How to fix it

Cause 1 of 5

A dependency has not been updated for your major version of the peer.

Read the block npm prints — it names the package, what it found, and what it wants. Then upgrade that package to a release that lists your version as a valid peer; npm view <package> peerDependencies and the changelog tell you which release that is.

Cause 2 of 5

You control the peer's version and can align it instead.

If the conflict is over a library your own project pins, install a version every dependent accepts. Downgrading one direct dependency is often cleaner than forcing the tree.

Cause 3 of 5

The tree is stale rather than genuinely conflicting.

Delete node_modules and package-lock.json and run npm install so npm re-solves from scratch. Regenerate the lockfile — do not delete it permanently; it is what makes installs reproducible.

Cause 4 of 5

Nothing compatible exists yet and you have checked the mismatch is cosmetic.

npm install --legacy-peer-deps installs anyway and ignores peer ranges. This can produce a tree that genuinely breaks at runtime, so test the affected feature deliberately, record the flag in .npmrc so CI matches local exactly, and remove it once the package updates. Prefer it over --force, which is broader and overrides more checks.

Cause 5 of 5

You need a single version of a peer that npm has duplicated.

overrides in package.json forces one resolution across the whole tree. It is powerful and easy to get wrong, so scope it to the exact package and check npm ls <name> shows a single copy afterwards.

Stopping it coming back

Upgrade framework majors and their ecosystem packages in the same change, and let Dependabot or Renovate surface peer incompatibilities in a PR rather than in a broken local install.

npm ERESOLVE peer dependency conflict — common questions

Why did npm 6 install this without complaining?
npm 6 ignored peer dependency conflicts silently and left you with whatever tree it happened to build. npm 7 started enforcing them. The conflicts were always there; only the reporting changed.
Is --legacy-peer-deps safe in CI?
It is safe only if you have verified the resulting tree works. If you use it, put it in the project's .npmrc so every install — local, CI, and Docker — resolves identically. A flag typed by hand in one place and not another is how a build passes locally and fails in production.
What is the difference between --force and --legacy-peer-deps?
--legacy-peer-deps ignores peer dependency ranges specifically. --force overrides that plus several other safety checks, including cache and version conflicts. Reach for the narrower one.

Test the fix before you paste it back

Reproducing the failure in a scratch file is usually faster than editing the real one. AltF Code is a free in-browser editor with real syntax highlighting for HTML, CSS, JavaScript, TypeScript, Python, SQL and JSON, and it runs HTML, CSS and JavaScript live in a preview panel. No install and no sign-up.

Open the editor