[英]Module not found: Error: Can't resolve '@material-ui/core' in 'C:\Users\Meenakshi\OneDrive\Documents\react apps\memories\client\src'
I was working on a web application which uses MERN.我正在开发一个使用 MERN 的 web 应用程序。 I have installed @material-ui/core but it is throwing an error like Module not found: Error: Can't resolve '@material-ui/core' in 'C:\Users\Meenakshi\OneDrive\Documents\react apps\memories\client\src' My import files are-
我已经安装了@material-ui/core,但是它抛出了一个错误,比如找不到模块:错误:无法在'C:\Users\Meenakshi\OneDrive\Documents\react apps\ 中解析'@material-ui/core' memory\client\src' 我的导入文件是-
import React from "react";
import { Container, AppBar, Typography, Grow, Grid } from "@material-ui/core";
import memories from "./images/memories.png";
And the dependencies looks like-依赖项看起来像 -
"dependencies": {
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.3.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4"
}
I'm importing it using the command-我正在使用命令导入它-
$ npm install @material-ui/core
and have also tried-并且也尝试过——
$ npm install i @material-ui/core
Instead of importing whole material ui core, you can import specifically what you need.您可以专门导入您需要的内容,而不是导入整个材质 ui 核心。
for version 4.x Examples:对于版本 4.x示例:
import { makeStyles } from '@material-ui/core/styles';
import { Box, Grid } from '@material-ui/core';
and in your package.json在你的 package.json
"@material-ui/core": "^4.11.0",
if using version 5.x如果使用版本 5.x
npm install @mui/material @emotion/react @emotion/styled
import Button from '@mui/material/Button';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.