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: my-app@0.1.0
npm ERR! Found: react@16.14.0
npm ERR! node_modules/react
npm ERR! react@"^16.13.1" from the root project
npm ERR! peer react@">=16.8.0" from @emotion/react@11.7.1
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
Indeed, a sub-dependency of it, named @emotion/react@11.7.1, 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).