Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Module not found: Can't resolve '@mui/material/utils' : (v5, which included a name change.)

I can see this error when I attempted to import some Icons from material-ui. I installed some modules as advised, but still not fixed.

package.json

    "@material-ui/core": "^4.12.3",
    "@mui/icons-material": "^5.0.1",
    "@mui/lab": "^5.0.0-alpha.49",

I attempted to install /utils by using the following command,

$ npm install @mui/material/utils

ERROR:

npm ERR! code ENOLOCAL
npm ERR! Could not install from "@mui\material\utils" as it does not 
contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Han\AppData\Roaming\npm-cache\_logs\2021-10-03T21_47_03_649Z-debug.log

Is there anything I missed?

**After some reserch, I removed "@material-ui/core" and install "@mui/core" instead. I assume this error comes up since there is name changed from material to mui?

    "@mui/core": "^5.0.0-alpha.49",
    "@mui/icons-material": "^5.0.1",
    "@mui/lab": "^5.0.0-alpha.49",
    "@mui/utils": "^5.0.1",

Thanks.

like image 640
Han Avatar asked Oct 03 '21 21:10

Han


People also ask

Can't resolve '@ MUI icons material cancel?

To solve the error "Module not found: Error: Can't resolve '@mui/material'", make sure to install the package by opening your terminal in your project's root directory and running the command npm i @mui/material @emotion/react @emotion/styled and restart your development server. Copied!

How do I import makeStyles into material UI?

instead of makeStyles you can just create object with styles ( style={your styles} ) inside functional component and then use sx property( sx={style} ) on MUI component inside that functional component.

How do I remove material UI from react?

Basically you should install the new @mui packages , update your application code as needed and then you can remove old @material-ui packages. Following that guide you should do some changes or update some components depending on your application.


3 Answers

Try this command npm install @mui/material @emotion/react @emotion/styled

like image 164
SIDDHARTH MISHRA Avatar answered Oct 23 '22 13:10

SIDDHARTH MISHRA


Explanation

This error happens when installing the MUI icons package before installing the MUI component library. The MUI icons package needs @mui/material @emotion/react @emotion/styled packages to work properly.

Solution

Run one of the following lines

// with npm
npm install @mui/material @emotion/react @emotion/styled

// or if you prefer yarn
yarn add @mui/material @emotion/react @emotion/styled
like image 16
Gass Avatar answered Oct 23 '22 12:10

Gass


Try to install the main package.

 npm i @mui/material

This will definitely solve your problem

like image 1
Tahseen Quraishi Avatar answered Oct 23 '22 12:10

Tahseen Quraishi