material-ui:找不到模块:'./AccessAlarm'

问题描述 投票:0回答:1

我们有一个使用@ material-ui的项目。它基于:

  • create-react-app:3.4
  • 节点:10.18.1
  • 纱线:1.21.1
  • @ material-ui:4.9.x

这个问题很奇怪:我可以在本地使用yarn startyarn build,版本与服务器完全相同。但是,当我推送到服务器后,它失败了:

[4/4] Building fresh packages...
success Saved 1 new dependency.
info Direct dependencies
└─ @material-ui/[email protected]
info All dependencies
└─ @material-ui/[email protected]
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

有人对此有任何想法吗?谢谢。

reactjs material-ui yarn create-react-app
1个回答
0
投票

yarn cache clean可以解决问题。

© www.soinside.com 2019 - 2024. All rights reserved.