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 This Error Means

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

How to Fix It

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 It Happens

Two dependencies require incompatible versions of the same peer dependency.

A package declares a peer dependency range that does not match your installed version.

Lockfile drift or partial upgrades left the tree inconsistent.

How to Verify

Run npm ls and ensure the dependency tree is consistent.

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.

Prevention Tips

Avoid partial dependency upgrades across a monorepo.

Pin dependency versions and keep lockfiles committed.

Prefer libraries with accurate peer dependency ranges.

Where This Can Be Triggered

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