maher abedah
maher abedah

Reputation: 471

Module not found: Error: Can't resolve '@material-ui/core/styles' (when deploying to heroku)

i have a react application and trying to deploy it to Heroku and when runnung git push heroku master

Module not found: Error: Can't resolve '@material-ui/core/styles'

I searched for similar issues and installed the latest versions of npm, node and metarial-ui also i tried npm install @material-ui/core ..didn't work.

here is the full error-log file

-----> Build succeeded! =====> Downloading Buildpack: https://github.com/mars/create-react-app-inner-buildpack.git =====> Detected Framework: React.js (create-react-app) Writing static.json to support create-react-app Enabling runtime environment variables [email protected] build /tmp/build_a49639db14111a3c4e29b2f3e9e25c49 react-scripts build Creating an optimized production build... Failed to compile. Module not found: Error: Can't resolve '@material-ui/core/styles' in '/tmp/build_a49639db14111a3c4e29b2f3e9e25c49/src' npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! [email protected] build: react-scripts build npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above. npm ERR! A complete log of this run can be found in: npm ERR! /app/.npm/_logs/2018-10-08T20_29_28_807Z-debug.log ! Push rejected, failed to compile React.js (create-react-app) multi app. ! Push failed

and the project can be found on github react app using google Api

thanks for any help, I tried many ideas and came to no solution .

Upvotes: 18

Views: 85667

Answers (6)

user22301187
user22301187

Reputation: 11

Below command solves my error:

npm i @material-ui/core --force 

Upvotes: 1

for me was >> ‍npm i @material-ui/core --force

Upvotes: 1

indianwebdevil
indianwebdevil

Reputation: 5127

If you are using MUI 5 You need to change this

v5
import { withStyles } from '@mui/material/styles';


V4
import { withStyles } from '@material-ui/core/styles';

Upvotes: 8

Geeth Malinda
Geeth Malinda

Reputation: 21

Check your react version and run:

npm install @material-ui/core --save 

or run:

npm install @material-ui/core@next

Upvotes: 0

maher abedah
maher abedah

Reputation: 471

the problem was solved according to the answer from @samokasha , the solution was using npm install @material-ui/core --save

I used the same command before but I missed the --save

thanks for the help.

Upvotes: 29

kasho
kasho

Reputation: 526

Looks like your package.json file doesn't include material-ui. Try 'npm i -s @material-ui/core'

Upvotes: 2

Related Questions