next.js '@material-ui/core'应该列在项目的依赖项中

xt0899hw  于 2023-06-05  发布在  其他
关注(0)|答案(1)|浏览(187)

我试图在组件中添加一个类似Instagram的like按钮,但每当我从需要的地方导入所需的东西时,就会弹出此错误:“'@ material-ui/core'应列在项目的依赖项中。”
有关进口:

import FormControlLabel from '@material-ui/core/FormControlLabel';
import Checkbox from '@material-ui/core/Checkbox';
import Favorite from '@material-ui/icons/Favorite';
import FavoriteBorder from '@material-ui/icons/FavoriteBorder';

我试过运行'npm i -S @material-ui/icons'和'npm i -S @material-ui/core',即使它们已经在依赖项列表中,如下所示:

"dependencies": {
    "@emotion/react": "^11.11.0",
    "@emotion/styled": "^11.11.0",
    "@fontsource/roboto": "^5.0.1",
    "@fortawesome/react-fontawesome": "^0.2.0",
    "@material-ui/core": "^4.12.4",
    "@material-ui/icons": "^4.11.3",
    "@mui/icons-material": "^5.11.16",
    "@mui/material": "^5.13.2",
    "axios": "^0.21.1",
    "bootstrap": "^5.1.3",
    "firebase": "^8.2.0",
    "next": "12.0.7",
    "prop-types": "^15.7.2",
    "react": "17.0.2",
    "react-bootstrap": "^2.4.0",
    "react-dom": "17.0.2"
  },

我也尝试过像这样格式化导入:

import { FormControlLabel, Checkbox } from '@material-ui/core';
import { Favorite, FavoriteBorder } from '@material-ui/icons';

我也试过在导入中将@material-ui改为@mui,但似乎没有什么效果。

r7knjye2

r7knjye21#

正如另一条评论所说,我只需要删除.next文件夹并重新启动服务器。

相关问题