`npm ERR! ERESOLVE` Is Usually What Happens When Your Dependencies Disagree and Your Installer Finally Stops Pretending It Can Guess the Right Answer
A practical guide to fixing `npm ERR! ERESOLVE unable to resolve dependency tree` by reading peer dependency conflicts correctly, checking package ranges, and choosing the least-destructive resolution instead of slapping on `--force`.
Why this error matters:
ERESOLVEis not npm being dramatic. It is npm finally telling you that two packages want incompatible worlds and that blind installation would just hide the problem until runtime.
One of the most common frontend and Node setup failures now starts with some variation of:
npm ERR! ERESOLVE unable to resolve dependency treeThe first bad instinct is to treat it like a random installer tantrum and solve it with:
npm install --forceor:
npm install --legacy-peer-depsThose flags can unblock you, but they also make it easier to install a dependency graph that does not actually agree with itself. If the project later behaves strangely, you end up debugging symptoms instead of the real mismatch.
What the error usually means
Most ERESOLVE failures come from peer dependency conflicts.
A package is basically saying:
- “I work with React 18”
- another package says “I require React 19”
- your app currently has one of those, not both
npm used to be looser about this. Modern npm is more willing to stop and show you the conflict instead of papering over it.
Start by reading the actual conflict
Run the install command again and look for the two packages in conflict. Then inspect your tree:
npm ls react
npm ls typescript
npm ls eslintIf the problem is package metadata rather than the currently installed tree, inspect declared ranges:
cat package.jsonor, if you want one field fast:
npm pkg get dependencies
npm pkg get devDependenciesThe goal is to answer:
- which package is imposing the restrictive peer range
- whether your root package is pinned too high or too low
- whether a newer compatible version of the conflicting package exists
The clean fix order
1. Check whether one side simply needs an update
npm outdatedIf the plugin or framework package has a newer version that supports your current stack, upgrade that first.
For example:
npm install some-plugin@latest2. If the root dependency is the outlier, align it
If a plugin ecosystem is still on React 18 and you pulled React 19 into a project that is not ready, stepping back may be cleaner than forcing everything through.
npm install react@18 react-dom@183. Delete stale install state if the tree has already been churned
rm -rf node_modules package-lock.json
npm installThis does not solve a real version conflict by itself, but it clears old lockfile state once you have chosen a proper version combination.
When --legacy-peer-deps is acceptable
Use it only when:
- you understand the conflict
- the package combination is known to work in practice
- you need a temporary unblock for local testing
Example:
npm install --legacy-peer-depsThat is a tactical move, not a design decision.
A simple resolution workflow
npm ls
npm outdated
npm install package-causing-conflict@latest
rm -rf node_modules package-lock.json
npm installIf that still fails, align the framework version with the plugin ecosystem instead of piling on installer flags.
Final recommendation
Treat ERESOLVE as dependency information, not installer hostility. Read the conflicting peer ranges, decide which package set should win, then rebuild the tree cleanly. The real fix is usually version alignment, not --force.