1

I want Use MUI icons in my ReactJs project but when I start my project, I have an error.

Install MUI with npm install @mui/icons-material ... Import My Icon:

import HomeIcon from '@mui/icons/material/Home';

How Can I Solve This Error?

this is my error

Error text:

Module not found: Can't resolve '@emotion/react' in '.../@mui/styled-engine'
NearHuscarl
  • 66,950
  • 18
  • 261
  • 230
Amir Rezaie
  • 43
  • 1
  • 11

2 Answers2

3

Follow the installation guide here, you're missing those 2 styling packages in v5.

The icons from @mui/icons-material package depends on the SvgIcon component which comes from @mui/material. The component itself uses styled() and by default it uses emotion under the hood which means if you use MUI icons you need to install these 2 packages below too (aside from installing @mui/material):

npm install @emotion/react @emotion/styled
NearHuscarl
  • 66,950
  • 18
  • 261
  • 230
0

It seems like you imported it wrong. I am using the following packages:

"@mui/icons-material": "^5.0.1",
"@mui/lab": "^5.0.0-alpha.48",
"@mui/material": "^5.0.1",

and I have imported the icon you want by using:

import HomeIcon from '@mui/icons-material/Home';
elam
  • 83
  • 1
  • 7
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Oct 22 '21 at 18:31