Search code examples
reactjsmaterial-uiuuid

npm ERR code ERESOLVE facing this issue while trying to install react packages


I have materials-ui already installed and when i tried to install other react packages im getting this error and nothing related to npm is working properly please help

PS

C:\Users\panna\OneDrive\Desktop\forms\google_form> npm install @mui/lab
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR! 
npm ERR! While resolving: @material-ui/core@4.12.4
npm ERR! Found: react@18.2.0
npm ERR! node_modules/react
npm ERR!   peer react@"^17.0.0 || ^18.0.0" from @mui/base@5.0.0-alpha.105
npm ERR!   node_modules/@mui/base
npm ERR!     @mui/base@"5.0.0-alpha.105" from @mui/material@5.10.13
npm ERR!     node_modules/@mui/material
npm ERR!       @mui/material@"^5.10.13" from the root project
npm ERR!       1 more (@mui/lab)
npm ERR!     @mui/base@"5.0.0-alpha.105" from @mui/lab@5.0.0-alpha.107
npm ERR!     node_modules/@mui/lab
npm ERR!       @mui/lab@"*" from the root project
npm ERR!   peer react@"^17.0.0 || ^18.0.0" from @mui/material@5.10.13
npm ERR!   node_modules/@mui/material
npm ERR!     @mui/material@"^5.10.13" from the root project
npm ERR!     peer @mui/material@"^5.0.0" from @mui/lab@5.0.0-alpha.107
npm ERR!     node_modules/@mui/lab
npm ERR!       @mui/lab@"*" from the root project
npm ERR!   11 more (@mui/private-theming, @mui/styled-engine, @mui/system, ...)
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!   peer @material-ui/core@"^4.0.0" from @material-ui/icons@4.11.3
npm ERR!   node_modules/@material-ui/icons
npm ERR!     @material-ui/icons@"^4.11.3" from the root project
npm ERR!   @material-ui/core@"^4.12.4" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react@17.0.2
npm ERR! node_modules/react
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!     node_modules/@material-ui/icons
npm ERR!       @material-ui/icons@"^4.11.3" from the root project
npm ERR!     @material-ui/core@"^4.12.4" 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 C:\Users\panna\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\panna\AppData\Local\npm-cache\_logs\2022-11-13T18_48_18_070Z-debug-0.log
og

I tried uninstalling materials ui and many more thing whatever was availble on the net but couldnt find anything similar , it is my first time using reacts packages please help


Solution

  • This is because you are using React 18 with MUI v4 you can choose one of these approaches: Update your MUI to v5 or Downgrade your React Version to 17 or if you want to keep these version just simply use this flag --legacy-peer-deps for example: npm install @mui/lab --legacy-peer-deps

    then you can install everything But Preferably Update your MUI to version 5.