Home > Software engineering >  How to add the Material UI package to React app
How to add the Material UI package to React app

Time:05-12

I want to add material-ui/icon package to my react app. If I run npm install @mui/material @emotion/react @emotion/styled in my root folder I get the following error:

Invalid package name "material-ui/icons" of package "material-ui/icons@": name can only contain URL-friendly characters.

I also tried to install the package with the following commands:

yarn add @material-ui/icons

npm install @material-ui/core

npm install @emotion/react

yarn add @mui/material @emotion/react @emotion/styled

npm install --save material-ui/icon

Nothing of it worked. In the case of yarn I got the following error zsh: command not found: yarn because I don't have yarn installed. How can I install the package?

CodePudding user response:

Try this npm install @emotion/react @emotion/styled @mui/icons-material @mui/material

CodePudding user response:

Running the command below will install yarn.

sudo npm install -g yarn

And then just run the code below.

yarn add @mui/material @emotion/react @emotion/styled

  • Related