'Material Icons seem to be missing a dependency - @emotion?

I am following the instructions / reference by google at mui.com, however when I try to use them I get an error by webpack saying I need something called @emotion.

Is this actually necessary and if so why is it not included when I install material icons.

npm install @mui/icons-material

There is no mention of it in the instructions by mui.com.

I blindly installed @emotion/react and @emotion/styled and webpack will compile. Seems that react requires extra dependencies not mentioned in the guide.



Solution 1:[1]

This syntax is used when you need icons in use from Material UI.

npm install @mui/icons-material

However, if you don't use icons in your project design, and you do use Material UI instead of CSS, you can install them with the following syntax:

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

However, judging by the warning package requirements mentioned by you, namely @emotion. Then you can install the package with the syntax:

npm install @mui/material @mui/styled-engine-sc styled-components

Material UI is using emotion as a styling engine by default. If you want to use styled-components instead.

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 Fuad Zein