What This Error Means
npm could not resolve a compatible dependency tree (often peer dependency conflicts).
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) ornpm 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 lsand 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.
Common CLI Output
npm ERR! code ERESOLVEnpm 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
ERESOLVEwith 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