npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! While resolving: my-app@1.0.0
npm ERR! Found: react@19.0.0
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^18.0.0" from some-library@3.0.0
npm canβt figure out a set of package versions that satisfies all requirements. This is different from the peer dependency warning β ERESOLVE is a hard failure.
Fix 1: βlegacy-peer-deps
npm install --legacy-peer-deps
This uses npm v6 behavior which is less strict about peer dependencies. Works 90% of the time.
Fix 2: βforce
npm install --force
Forces installation, overriding conflicts. More aggressive than --legacy-peer-deps.
Fix 3: Update the Conflicting Package
# See which package is causing the conflict
npm ls react
# Update it
npm install some-library@latest
Often the latest version of the library supports your version of React/Node/etc.
Fix 4: Use overrides
Pin a specific version in package.json:
{
"overrides": {
"react": "19.0.0"
}
}
Then rm -rf node_modules package-lock.json && npm install.
Make βlegacy-peer-deps the Default
If youβre tired of adding the flag every time:
npm config set legacy-peer-deps true
Or add to .npmrc in your project root:
legacy-peer-deps=true
Related: npm Cheat Sheet Β· How Npm Install Actually Works