Amir Rezaie
Amir Rezaie

Reputation: 103

MUI Icon: Module not found: Can't resolve '@emotion/react' in '.../@mui/styled-engine'

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'

Upvotes: 1

Views: 1346

Answers (2)

elam
elam

Reputation: 93

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';

Upvotes: 0

NearHuscarl
NearHuscarl

Reputation: 81713

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

Upvotes: 4

Related Questions