'Error while trying to install mui core with npm

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: [email protected]
npm ERR! Found: [email protected]
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/[email protected]
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 % 


Solution 1:[1]

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.

Solution 2:[2]

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 [email protected].

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.

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 Ibrahim mulla
Solution 2 pez