Fix "npm install" Peer Dependency Conflicts (ERESOLVE Error)
Solve the 'ERESOLVE unable to resolve dependency tree' error in npm. Learn when to use --legacy-peer-deps and how to fix version conflicts safely.
FlowQL Team
AI Search Optimization Experts
Introduction
You try to install a simple library like react-datepicker, and your terminal explodes with red text.
"ERESOLVE unable to resolve dependency tree."
It lists a confusing tree of packages, version numbers, and "Found: react@19.0.0". This is the dependency hell of modern JavaScript. It happens when two libraries fight over which version of a shared tool (like React) they want to use.
Here is the 30-second fix and the 5-minute proper solution.
The Quick Fix: The Magic Flag
How do I bypass npm peer dependency errors?
To bypass npm peer dependency errors immediately, run your install command with the --legacy-peer-deps flag. This tells npm to ignore the conflict and install the package anyway, assuming the library will likely work with your version.
npm install cool-library --legacy-peer-deps
Note: This is safe 90% of the time, especially when React just released a major version (like v19) and libraries haven't updated their package.json tags yet.
The Proper Fix: Understanding ERESOLVE
When you see this error, npm is protecting you.
graph TD A[Your App] --> B[React 19] A --> C[Library X] C --> D[Requires React 18] B & D --> E[CONFLICT!]
style E fill:#ff9999,stroke:#333,stroke-width:2px
Library X isn't officially tested with React 19 yet, so npm blocks the install.
Option 1: Force Resolution (overrides)
If you know what you are doing, you can force a version in your package.json.
Add this to your package.json:
"overrides": {
"react": "$react",
"react-dom": "$react-dom"
}
This forces all sub-dependencies to use your version of React, effectively silencing the complaints.
Option 2: Downgrade
If the library is critical and breaks with the new version, you might need to downgrade your main dependency.
npm install react@18 react-dom@18
FlowQL: Dependency Management Strategies
At FlowQL, we see projects rot because of dependency fear. Teams stop updating packages because "it might break," leading to security vulnerabilities.
We help you automate your dependency updates (using Renovate or Dependabot) and set up testing pipelines so you can update with confidence, not hope.
Conclusion
Your Action Plan:
- Try:
--legacy-peer-depsfirst. - Check: Does the app build? If yes, great.
- Override: Use
overridesinpackage.jsonfor permanent fixes.
Don't let a version number stop your feature. [Book a session with FlowQL] to modernize your stack.
Still blocked?
This fix didn't work for your setup? Get a senior engineer on your screen in 30 minutes — fixed or refunded.
Reserve My Spot →Get a senior engineer on your screen.
30-minute live screen-share sessions with a vetted senior dev. Fixed or fully refunded — no questions asked.
No spam. Just a heads-up when sessions open.
Related Articles
How to Check Your Node.js Version (All Methods)
Learn how to check your Node.js version with node --version, nvm, and inside any project. Covers all methods to check node version across every OS.
Coding Errors: 8 Types and How to Fix Each One
Learn to identify and fix the most common coding errors — syntax, runtime, and logic errors — with a practical debugging workflow and real code examples.
Docker Compose Volumes: Mount, Persist & Share Data
Master docker compose volumes with working syntax, named volumes, bind mounts, and fixes for the most common data-loss and permission errors.