【发布时间】:2021-10-30 10:24:48
【问题描述】:
我正在尝试使用官方指南将我的 NextJS 项目从 Material UI v4 升级到 v5:https://mui.com/guides/migration-v4/
完成所有步骤后,当我启动服务器时,我的控制台中出现以下错误:
Module not found: Can't resolve 'react'
Import trace for requested module:
./../node_modules/@emotion/react/dist/emotion-react.browser.esm.js
./../node_modules/@mui/styled-engine/index.js
./../node_modules/@mui/system/esm/index.js
./../node_modules/@mui/core/Popper/Popper.js
./../node_modules/@mui/core/Popper/index.js
./../node_modules/@mui/core/index.js
./../node_modules/@mui/material/utils/index.js
./../node_modules/@mui/icons-material/utils/createSvgIcon.js
./../node_modules/@mui/icons-material/Menu.js
./components/global/LodAppBar.jsx
./pages/_app.jsx
我尝试删除我的node_modules 文件夹并重新安装所有模块,但没有成功。我已确保所有 @material-ui 软件包也已从我的 package.json 文件中删除。这些是我对 package.json 的依赖:
"dependencies": {
"@auth0/auth0-react": "^1.4.0",
"@date-io/date-fns": "^1.3.13",
"@emotion/react": "^11.5.0",
"@emotion/styled": "^11.3.0",
"@mui/material": "^5.0.6",
"@mui/styles": "^5.0.2",
"@sentry/react": "^6.11.0",
"@sentry/tracing": "^6.11.0",
"babel-preset-next": "^1.4.0",
"d3": "7.1.1",
"date-fns": "^2.20.2",
"date-fns-timezone": "0.1.4",
"dotenv": "^8.2.0",
"formik": "^2.2.6",
"logrocket": "^2.0.0",
"logrocket-react": "^4.0.1",
"luxon": "^1.26.0",
"next": "^11.1.1",
"next-optimized-images": "^2.6.2",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-swipeable-views": "^0.13.9"
},
【问题讨论】:
-
尝试删除
yarn.lock和package-lock.json并重新安装。 -
谢谢,好像可以了!随意张贴作为答案,我会为你接受。
标签: reactjs material-ui next.js