material-ui:找不到模块:'./AccessAlarm'
Posted
技术标签:
【中文标题】material-ui:找不到模块:\'./AccessAlarm\'【英文标题】:material-ui: Cannot find module: './AccessAlarm'material-ui:找不到模块:'./AccessAlarm' 【发布时间】:2020-06-10 01:40:10 【问题描述】:我们有一个使用@material-ui 的项目。它建立在:
创建反应应用程序:3.4 节点:10.18.1 纱线:1.21.1 @material-ui: 4.9.x这个问题很奇怪:我可以在本地yarn start
和yarn build
,版本和服务器完全一样。但是,在我推送到服务器后,它失败了:
[4/4] Building fresh packages...
success Saved 1 new dependency.
info Direct dependencies
└─ @material-ui/icons@4.9.1
info All dependencies
└─ @material-ui/icons@4.9.1
Done in 8.27s.
+ yarn run build:dev
yarn run v1.21.1
$ cp .env.sample .env && react-scripts build
The following changes are being made to your tsconfig.json file:
- compilerOptions.paths must not be set (aliased imports are not supported)
Creating an optimized production build...
Failed to compile.
./node_modules/@material-ui/icons/esm/index.js
Cannot find module: './AccessAlarm'. Make sure this package is installed.
You can install this package by running: yarn add ./AccessAlarm.
服务器搭建步骤为:
node -v
rm yarn.lock
rm -rf build node_modules
yarn install
yarn add @material-ui/core // I have tried to run with and w/o these two lines
yarn add @material-ui/icons
yarn run build:dev
有人对此有任何想法吗?谢谢。
【问题讨论】:
【参考方案1】:yarn cache clean
可以解决问题。
【讨论】:
【参考方案2】:在我的情况下,错误发生在本地,这是修复它的原因:
yarn add @material-ui/core
然后
yarn link
然后
yarn upgrade @material-ui/core
然后
yarn upgrade @material-ui/icons
然后
npm start
【讨论】:
以上是关于material-ui:找不到模块:'./AccessAlarm'的主要内容,如果未能解决你的问题,请参考以下文章
找不到模块“material-ui/styles/MuiThemeProvider”的声明文件?
未找到模块:错误:无法解析“@material-ui/core/styles”(部署到 heroku 时)