'ERESOLVE unable to resolve dependency tree - for @mui/material
I am trying to install material UI as described on the home page, but I get a dependency tree error :
C:\dev\shape-shop-front-end>npm install @mui/material
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR! react@"^16.13.1" from the root project
npm ERR! peer react@">=16.8.0" from @emotion/[email protected]
npm ERR! node_modules/@emotion/react
npm ERR! node_modules/@mui/material
npm ERR! @mui/material@"*" from the root project
npm ERR!
In my package.json I have "react": "^16.13.1" .
As I understand it, this error is saying that a MUI package needs react 16.8.0
Solution 1:[1]
Indeed, a sub-dependency of it, named @emotion/[email protected], has listed the following peer dependencies you have to meet:
"peerDependencies": {
"@babel/core": "^7.0.0",
"react": ">=16.8.0"
}
source: https://github.com/emotion-js/emotion/blob/main/packages/react/package.json
I think this has to do with how new versions of NPM deal with peer dependencies: https://github.blog/2021-02-02-npm-7-is-now-generally-available/
As your react version seems OK, I would go with this suggestion:
You have the option to retry with --force to bypass the conflict or --legacy-peer-deps command to ignore peer dependencies entirely (this behavior is similar to versions 4-6).
Solution 2:[2]
Looks like updating dependencies in package.json is the only way to make this happen now.
$ npm install -g npm-check-updates
$ ncu -u
$ npm install
or see how to update each dependency in package.json
after updating, now try to install your material UI.
Solution 3:[3]
Try using --force. That's what worked for me
npm install @mui/material --force
I have a feeling it's a dependency conflict that came with the recent React upgrade...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Trevor |
| Solution 2 | Ajay jangid |
| Solution 3 | chiziivictor |
