npm refuses to install a React library because of peerDependencies
The package react@15.3.2 does not satisfy its siblings' peerDependencies requirementsShort answer
The library declares which React version it works with, and your project has a different one. npm normally warns and resolves it, but with strict-peer-deps on any conflict becomes a failure. Check that setting, then upgrade the library to a release that lists your React, and use legacy-peer-deps only as a last resort.
Fix it fast
1Find out which cause you have
Read the full npm output: it names the package that asks for a React version and the version you have. Also print the npm settings that change peer handling.
npm ls react npm config get strict-peer-deps npm config get legacy-peer-deps2Match what you see, then jump to its fix
What does the error look like?
The package react@15.3.2 does not satisfy its siblings' peerDependencies requirements
Cause 1 of 2
strict-peer-deps is turned on
1Check
With strict-peer-deps set, any conflicting peerDependencies are treated as an install failure instead of a warning.
cat .npmrc ~/.npmrc 2>/dev/null | grep -i peer2Fix
Remove the setting, so npm warns about the conflict and resolves using the nearest non-peer dependency.
npm config delete strict-peer-deps
npm install3Verify
Install again and check the library is in the tree.
npm ls reactConfirmed by docs.npmjs.com
Cause 2 of 2
The library supports a different React than your project
1Check
Compare your React version with the peerDependencies of the library version you are installing.
npm view @mui/material peerDependencies2Fix
Install a release of the library whose peer range includes your React. If none exists yet, install while ignoring peer dependencies, knowing that npm then does not enforce the contract.
npm install @mui/material@latest
# last resort, ignores peerDependencies like npm 3 to 6 did
npm install @mui/material --legacy-peer-deps3Verify
Start the app and use a component from the library.
npm ls react && npm startConfirmed by docs.npmjs.com
How do I stop it coming back?
- Upgrade React and its ecosystem libraries together, not one at a time.
- Check a library's peerDependencies before adopting it.
- Avoid --force; npm's docs say it removes protections against common mistakes.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- TaxiDexMy own multi-tenant taxi dispatch SaaS: API, dispatcher portal, driver and passenger apps, and the servers underneath.
- QistLockA NestJS and React SaaS driving an Android Device Owner agent that locks financed phones when payments lapse.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
Related fixes
Web apps
React shows Attempted import error when importing a component or function
Attempted import error:
The build found the file but not the name you asked for.
2 causes, each with a fixWeb apps
AxiosError Network Error with code ERR_NETWORK in a React app
Network Error
ERR_NETWORK means the request produced no readable response.
4 causes, each with a fixWeb apps
Axios get works with a URL string but ignores the object passed as the second argument
The server log shows a GET with no query string
axios.get takes a URL and an optional config object.
3 causes, each with a fixWeb apps
Can't resolve '../axios' in a React project
Module not found: Error: Can't resolve '../axios'
A path that starts with ./ or ../ is a file path, not the axios package.
3 causes, each with a fixWeb apps
Axios returns 401 from a React app but the login works elsewhere
Error: Request failed with status code 401
A 401 means the server received the request without valid credentials.
3 causes, each with a fixWeb apps
An axios call never finishes when the API server stops answering
code: 'ECONNABORTED'
Axios has no timeout unless you give it one: the default is 0, which means wait forever.
3 causes, each with a fix