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.
Subscribe to our blog
Get the latest guides and insights delivered to your inbox.
Join the FlowQL waitlist
Get early access to our AI search optimization platform.
Related Articles
Fix Cursor Context Window Exceeded Error (2026)
Cursor showing 'Context Window Exceeded'? Start a new thread, add .cursorignore to exclude node_modules and lockfiles, and reference files with @File instead of open tabs.
Fix Cursor Shadow Workspace 100% CPU Usage (2026)
Is Cursor AI slowing down your machine? Learn how to manage the 'Shadow Workspace' indexing process, optimize your CPU usage, and fix Cursor Helper lag.
Fixing Radix UI Dependency Conflicts in Shadcn (2026)
Conflicting Radix UI versions breaking your Shadcn components? Learn how to use npm overrides, clean your lockfile, and fix peer dependency errors in your UI library.