Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Next.js and React

npm cannot resolve the dependency tree when installing MUI icons

Errornpm error code ERESOLVE

Short 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.

  • Applies to npm 10, Node.js 22, @mui/icons-material 7, React 19
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 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 peerDependencies
  2. 2Match what you see, then jump to its fix

    1. 1The 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. 2The 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. 3The 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

What does the error look like?

  • npm error code ERESOLVE
  • npm 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 peerDependencies

2Fix

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/styled

3Verify

The install finishes and the tree has one version of each package.

npm ls @mui/material @mui/icons-material

Confirmed by raw.githubusercontent.com

Did this fix it?

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 peerDependencies

2Fix

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@19

3Verify

Run the install again without extra flags.

npm install @mui/icons-material

Confirmed by mui.com

Did this fix it?

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 react

2Fix

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-deps

3Verify

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 build

Confirmed by docs.npmjs.com

Did this fix it?

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:

Related fixes

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.