npm cannot resolve the dependency tree when installing MUI icons
npm error code ERESOLVEShort answer
npm 7 and later installs peer dependencies and stops when they clash. @mui/icons-material declares peers on @mui/material and react, so an older Material UI or an unsupported React makes the install fail. Read the conflict, align versions, and use legacy-peer-deps only as a last resort.
Fix it fast
1Find out which cause you have
Read the lines under the ERESOLVE message. They name the package that is found and the peer range that is required. Then list what you have.
npm ls @mui/material react npm view @mui/icons-material@latest peerDependencies2Match what you see, then jump to its fix
- 1
The conflict names @mui/material with a version that does not satisfy what @mui/icons-material asks for.@mui/icons-material and @mui/material are on different versionsFix - 2
The conflict names react with a peer range such as ^17.0.0 || ^18.0.0 || ^19.0.0.Your React version is outside the supported rangeFix - 3
The conflict is between a third package and a peer, not between MUI packages.Another package pins an old peer, and you must go on anywayFix
- 1
What does the error look like?
npm error code ERESOLVEnpm error ERESOLVE unable to resolve dependency tree
Cause 1 of 3
@mui/icons-material and @mui/material are on different versions
1Check
The package.json of @mui/icons-material lists @mui/material as a peer. Compare it with the version your app has.
npm ls @mui/material
npm view @mui/icons-material@latest peerDependencies2Fix
Install both packages in one command so npm picks versions that satisfy each other. Either upgrade Material UI, or pick an icons release whose peers accept the Material UI you keep (npm view shows peers per version).
npm install @mui/material@latest @mui/icons-material@latest @emotion/react @emotion/styled3Verify
The install finishes and the tree has one version of each package.
npm ls @mui/material @mui/icons-materialConfirmed by raw.githubusercontent.com
Cause 2 of 3
Your React version is outside the supported range
1Check
The icons package accepts only certain React majors. Check the one in your package.json.
npm ls react
npm view @mui/icons-material@latest peerDependencies2Fix
Move React and react-dom into the supported range, or install an older icons release whose peers accept your React.
npm install react@19 react-dom@193Verify
Run the install again without extra flags.
npm install @mui/icons-materialConfirmed by mui.com
Cause 3 of 3
Another package pins an old peer, and you must go on anyway
1Check
Find out which package pulls the old version.
npm explain react2Fix
Upgrade that package first. If you cannot, --legacy-peer-deps makes npm ignore peer dependencies as npm 3 to 6 did. npm warns against it because the peer contract is no longer enforced. --force is a different, broader override.
npm install @mui/icons-material --legacy-peer-deps3Verify
Run the app and the build. A missing or wrong peer shows up as a runtime error, so test the pages that use icons.
npm run buildConfirmed by docs.npmjs.com
How do I stop it coming back?
- Install @mui/material and @mui/icons-material in one npm command, so npm solves them together.
- Read npm ls output after each upgrade of React or Material UI.
- Do not store legacy-peer-deps in .npmrc for the whole team without writing down why.
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