Error while trying to install mui core with npm

Viewed 3790

I just deployed a new create-react-app and still receiving this same error message. I installed MUI and am receiving a 'unable to resolve dependency tree'

    npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: eat-blended-web@0.1.0
npm ERR! Found: react@18.1.0
npm ERR! node_modules/react
npm ERR!   react@"^18.1.0" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^16.8.0 || ^17.0.0" from @material-ui/core@4.12.4
npm ERR! node_modules/@material-ui/core
npm ERR!   @material-ui/core@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR! 
npm ERR! See /Users/rodriguezmedia/.npm/eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/rodriguezmedia/.npm/_logs/2022-05-13T00_57_27_262Z-debug-0.log
rodriguezmedia@Frankies-MacBook-Air-2 eat-blended-web % 
4 Answers

instead of using "npm install @material-ui/core", just refer to "npm install @mui/material" and for mui icons just install "npm install @mui/icons-material".

for more details just go to "https://www.npmjs.com/package/@mui/icons-material" this page.

The error is telling you that the package you're trying to install has react@"^16.8.0 || ^17.0.0" in its peer dependencies, but you're currently using react@18.1.0.

You can get around this and install your package by including --legacy-peer-deps at the end of your command. For example:

npm install @mui/material --legacy-peer-deps

Keep in mind that peer dependencies are modules that the package is designed to work with. Using this flag to proceed with the installation can cause unintended and sometimes breaking changes. Since React 18 is new, some packages have not been updated to specifically include it in their peer dependencies.

Please try this command

npm install @mui/material --legacy-peer-deps

Related