简体   繁体   中英

A problem with Material UI - Module not found: Can't resolve '@material-ui/icons/Add'

I am having problem with material ui. It worked for my first two projects but suddenly now its showing this error:

Module not found: Can't resolve '@material-ui/icons/Add' in 'E:\Projects\Slack-clone\slack-clone\src'

This is one of my components:

import React from 'react';
import "./Header.css";
import { Avatar } from '@material-ui/core';
import AddIcon from '@material-ui/icons/Add';

function Header() {
    return (
        <div className="header">
            <div className="header_left">
                <Avatar className="header_avatar" alt="soham bhosale" src=""/>
              <AddIcon />
        </div>

and this is my package.json after installing material-ui:

{
  "name": "slack-clone",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.11.10",
    "@testing-library/react": "^11.2.6",
    "@testing-library/user-event": "^12.8.3",
    "react": "^17.0.2",
    "react-dom": "^17.0.2",
    "react-scripts": "4.0.3",
    "web-vitals": "^1.1.1"
  }

Try this

npm install @material-ui/icons

And after that please check package.json you will find your package and after that you can try like this import AccessAlarmIcon from '@material-ui/icons/AccessAlarm';

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM