Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

material-ui: Cannot find module: './AccessAlarm'

We have a project using @material-ui. It's built upon:

  • create-react-app: 3.4
  • node: 10.18.1
  • yarn: 1.21.1
  • @material-ui: 4.9.x

This problem is weird: i can yarn start and yarn build locally, the versions are exactly the same as server. However, after I push to server, it failed:

[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.

The building steps on server is:

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

Anyone has any ideas about this? Thanks.

like image 946
Joy Avatar asked Jan 26 '26 00:01

Joy


2 Answers

yarn cache clean does the trick.

like image 97
Joy Avatar answered Jan 28 '26 14:01

Joy


In my case the error was occuring locally and this is what fixed it:

yarn add @material-ui/core

Then

yarn link  

Then

yarn upgrade @material-ui/core  

Then

yarn upgrade @material-ui/icons  

Then

npm start
like image 27
Justice Bringer Avatar answered Jan 28 '26 16:01

Justice Bringer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!