Since npm 7, peer dependencies are enforced strictly. When two packages disagree about a peer (commonly React versions), the install aborts. Here is how to read the conflict and fix it the right way.
The Error
npm ERR! ERESOLVE unable to resolve dependency tree. Could not resolve dependency: peer react@"^18.0.0" from some-lib@2.0.0
Step 1: Read Who Wants What
The error names the package and the peer version it requires versus the version you have. That tells you whether to upgrade the dependent package or wait for it to support your version.
The Quick Unblock
# Tells npm to use the older, lenient peer resolution
npm install --legacy-peer-depsWarning
--force and --legacy-peer-deps install anyway, but the conflict is real. The library may genuinely not support your React version — test thoroughly before shipping.
The Proper Fix
- Upgrade the conflicting library to a version that supports your peer (
npm install some-lib@latest). - Or align your core dependency to the version the library expects.
- Pin the resolution in package.json
overridesif you must force a single version across the tree.
