Understanding and Resolving npm ERESOLVE Dependency Conflicts

Resolve npm ERESOLVE peer dependency conflicts the right way: identify the real mismatch, align versions, use overrides safely, and know when pnpm or Yarn is a better fit.
Published:
Aleksandar Stajić
Updated: March 16, 2026 at 09:12 AM
Understanding and Resolving npm ERESOLVE Dependency Conflicts

Understanding and Resolving npm ERESOLVE Dependency Conflicts

An npm ERESOLVE error means npm couldn't build a dependency tree that satisfies all version rules — most often because of peer dependencies. Since npm 7, peer dependencies are handled strictly during install, so conflicts that previously installed “anyway” now fail fast.

That strictness reduces runtime surprises, but it can block installs when one package expects older versions than your project.

Quick Triage: Find the Actual Conflict

Before you force anything, identify who requires what. These commands usually pinpoint the culprit in under a minute.

npm -v
node -v

# show dependency chain
npm ls @tensorflow/tfjs
npm ls react

# show peer dependency requirements
npm view @tensorflow-models/handpose peerDependencies

# explain why a version was chosen
npm explain @tensorflow/tfjs

Why Peer Dependency Conflicts Happen

Peer dependencies are compatibility contracts. A library says: “I don't ship React / TFJS myself — you must provide a compatible version.” Conflicts happen when two packages demand incompatible version ranges.

  • Package A requires @tensorflow/tfjs ^3, but your project installs @tensorflow/tfjs@4.
  • A plugin requires react@^17, while your app is on react@18.
  • You mixed majors in a package family (e.g. tfjs core v4, backends still v3).

How to Fix npm ERESOLVE (Safest → Most Aggressive)

1) Align Versions (Best Long-Term Fix)

Keep one compatible major across the entire dependency family. This is the fix that survives CI, deployments, and future upgrades.

// package.json (example: align tfjs family on v3)
{
  "dependencies": {
    "@tensorflow/tfjs": "^3.21.0",
    "@tensorflow/tfjs-backend-webgl": "^3.21.0",
    "@tensorflow/tfjs-backend-cpu": "^3.21.0",
    "@tensorflow-models/handpose": "^0.0.7"
  }
}
rm -rf node_modules package-lock.json
npm install

2) Use npm "overrides" (Controlled Forcing, npm 8+)

Use overrides when a transitive dependency pulls the wrong version. This is safer than --force, but you must test runtime behavior.

// package.json
{
  "overrides": {
    "@tensorflow/tfjs": "^4.0.0",
    "@tensorflow/tfjs-backend-webgl": "^4.0.0",
    "@tensorflow/tfjs-backend-cpu": "^4.0.0"
  }
}
rm -rf node_modules package-lock.json
npm install

3) --legacy-peer-deps (Fast Unblock, Less Safety)

Bypasses strict peer resolution and installs anyway. Good for quick experiments — risky as a default in production.

npm install --legacy-peer-deps

4) --force (Last Resort)

Forces an install even when npm knows the tree is inconsistent. Use only if you accept potential runtime breaks.

npm install --force

5) Clean Install Checklist (Fixes Weird Lockfile States)

rm -rf node_modules package-lock.json
npm cache verify
npm install

npm vs pnpm vs Yarn: Practical Differences

All three can hit peer conflicts, but they differ in speed, node_modules strategy, and how quickly they expose "hidden" dependency mistakes.

npm (v7+): strict by default

  • Pros: catches incompatible peer combos early; predictable CI.
  • Cons: blocks installs more often; people reach for flags.
  • Best for: teams that want strict correctness over convenience.

pnpm: fast, disk-efficient, stricter dependency access

pnpm uses a global content-addressable store and links packages. Installs are typically faster and use less disk. Its stricter layout can reveal missing direct dependencies earlier.

corepack enable
corepack prepare pnpm@latest --activate

pnpm install

Yarn: strong workspaces tooling, flexible resolutions

Yarn is popular in monorepos. Depending on Yarn version/config it can feel more forgiving, but the big win is workspaces and its ability to pin versions via resolutions.

corepack enable
corepack prepare yarn@stable --activate

yarn install

# package.json (Yarn) -> "resolutions": { "react": "18.2.0" }

Conclusion

For production: prefer aligning versions or controlled overrides. Use --legacy-peer-deps to unblock quickly, and reserve --force for last resort. If installs are slow or the repo is large, pnpm is often a strong upgrade. If workspaces and strict pinning matter, Yarn is a good fit.

Copy/Paste Snippets

# safest: align versions
rm -rf node_modules package-lock.json
npm install

# controlled: overrides
# package.json -> "overrides": { "pkg": "version" }

# quick unblock
npm install --legacy-peer-deps

# last resort
npm install --force

Related Articles

How to Know Whether an AI Agent Actually Used the Right Evidence

How to Know Whether an AI Agent Actually Used the Right Evidence

An AI agent can cite sources and still use the wrong evidence. This article introduces a practical method for checking claim support, source authority, applicability, provenance, and whether the evidence actually influenced the answer.

Enterprise Start Here: Your Gateway to Operational Excellence

Enterprise Start Here: Your Gateway to Operational Excellence

New to our enterprise platform? This guide provides a structured onboarding path, from foundational reference models to actionable playbooks, runbooks, and assessments designed for seamless implementation.

Should You Buy a 5G OpenWrt Router with Old Firmware? ZBT Z8102AX as a Practical Example

Should You Buy a 5G OpenWrt Router with Old Firmware? ZBT Z8102AX as a Practical Example

Buying a 5G OpenWrt router with older firmware can make sense, but only under the right conditions. The ZBT Z8102AX shows both sides clearly: the hardware is useful, the modem works, and the router stayed stable in testing, but OpenWrt 21.02, weak packaging and unclear upgrade paths require a careful buying decision.

MCP vs A2A vs UCP vs AP2 vs A2UI: The Agent Protocol Stack Explained

MCP vs A2A vs UCP vs AP2 vs A2UI: The Agent Protocol Stack Explained

MCP, A2A, UCP, AP2 and A2UI are often presented as competing agent standards. They mostly solve different interoperability problems. This guide maps each protocol to the boundary it actually standardizes—and shows how they can work together in one production system.

Comprehensive Guide to Evaluation Harness: Mastering LLM Performance Evaluation

Comprehensive Guide to Evaluation Harness: Mastering LLM Performance Evaluation

This guide provides a detailed walkthrough of Evaluation Harness, an essential framework for rigorously assessing large language model (LLM) capabilities in enterprise LLMOps pipelines. Learn setup, best practices, and advanced techniques to ensure reliable model benchmarking and optimization.

Comprehensive Metrics Guide for Delivery and Change Management

Comprehensive Metrics Guide for Delivery and Change Management

This guide provides a detailed overview of essential metrics for enterprise delivery and change management, helping teams measure performance, optimize processes, and drive continuous improvement. Discover key indicators, calculation methods, and best practices to align your metrics with business outcomes.

Enterprise AI Architecture: What Changes When AI Enters a Company

Enterprise AI Architecture: What Changes When AI Enters a Company

Enterprise AI architecture explains how AI changes company systems across data authority, identity, permissions, providers, risk, governance, evaluation, compliance and operations.

ZBT Z8102AX 5G OpenWrt Router Review: Dual SIM, RM500U-EA and an Honest Assessment

ZBT Z8102AX 5G OpenWrt Router Review: Dual SIM, RM500U-EA and an Honest Assessment

The ZBT Z8102AX is an unusual 5G router with an OpenWrt base, a dual-SIM concept, and a Quectel RM500U-EA modem. In testing, it shows clear strengths in flexibility, interfaces, and mobile connectivity, but also the typical weaknesses of a vendor-modified OpenWrt build.

Computer-Use Agents: Why a Successful Demo Can Still Be an Unreliable System

Computer-Use Agents: Why a Successful Demo Can Still Be an Unreliable System

Computer-use agents can now complete impressive browser and desktop workflows, but one successful run proves capability—not reliability. This article shows how to test repeatability, environmental robustness, long-horizon control, state awareness, outcome verification, and safe goal handling.

Air-Gapped AI: How AI Systems Work Without Internet or Cloud Access

Air-Gapped AI: How AI Systems Work Without Internet or Cloud Access

Air-gapped AI runs models, RAG and AI applications inside an isolated security domain without internet or cloud dependencies. Learn how models, data, updates and tools operate offline.

Vector Databases, Embeddings and Reranking: Three Different Parts of Retrieval

Vector Databases, Embeddings and Reranking: Three Different Parts of Retrieval

Embeddings represent meaning, vector databases retrieve candidates, and rerankers refine results. Learn how these three retrieval layers differ and work together in RAG.

OpenAI Agents API vs Agents SDK vs Responses API: What Should You Build On in 2026?

OpenAI Agents API vs Agents SDK vs Responses API: What Should You Build On in 2026?

OpenAI’s agent stack changed in September 2026. This architecture guide separates the Agents API, Agents SDK, Responses API, and Codex SDK by runtime ownership—so teams can choose the right control boundary instead of comparing product names.