Error Knowledge Base npm ERESOLVE

npm ERR! code ERESOLVE

npm failed with ERESOLVE because it could not build a dependency tree that satisfies the requested versions and peer dependency constraints.

Affected versions: npm v7.0.0 and newer (most common).

What Broke in the Dependency Graph

npm failed with ERESOLVE because it could not build a dependency tree that satisfies the requested versions and peer dependency constraints.

This is npm refusing to continue with a dependency graph that does not make sense. The important detail is which versions or peer requirements disagree, not just the final error code.

Repair the dependency graph

Read the first conflicting peer dependency pair in the npm output (it usually names the exact packages and versions).

Prefer fixing the versions (upgrade/downgrade) so peer ranges line up.

As a temporary unblock, use npm install --legacy-peer-deps (skips peer resolution) or npm install --force (may produce a broken runtime).

If you use workspaces, ensure all workspace packages agree on peer dependency versions.

Why Resolution Broke

Usually this comes down to two dependencies require incompatible versions of the same peer dependency, a package declares a peer dependency range that does not match your installed version, or lockfile drift or partial upgrades left the tree inconsistent.

Prove the Graph Is Clean Again

Run npm ls and ensure the dependency tree is consistent, and run your test/build command to confirm runtime behavior is correct.

Manual dependency inspection

Inspect peer dependencies:npm view <pkg>@<version> peerDependencies

If you must keep multiple versions, consider isolating via separate packages/workspaces.

Examples

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree

How npm resolves dependencies

npm resolves dependencies by combining semver ranges into a single tree. Peer dependencies add constraints that must be satisfied by the parent project. When constraints cannot be satisfied, npm throws ERESOLVE with the conflicting packages.

Keep the Dependency Graph Healthy

To prevent this, avoid partial dependency upgrades across a monorepo, pin dependency versions and keep lockfiles committed, and prefer libraries with accurate peer dependency ranges.

Docs and source code

github.com/npm/cli/blob/417daa72b09c5129e7390cd12743ef31bf3ddb83/workspaces/arborist/lib/arborist/build-ideal-tree.js

Open-source npm CLI code reference tied to this error code. - GitHub

    const curNode = node.resolve(edge.name)
    const current = curNode.explain()
    return {
      code: 'ERESOLVE',
      current,
      // it SHOULD be impossible to get here without a current node in place,
      // but this at least gives us something report on when bugs creep into

Need help or found a mistake? Contact RepoFlow support for questions.

Join our mailing list