0

So, im trying to run a nextjs node app that also has Material-UI dependency in Heroku (using the default node webpack). When Ii run my app from the browser, I get the below error. In my packages.json i have the below dependencies:

> "dependencies": {
>     "@material-ui/core": "latest",
>     "@material-ui/icons": "latest",
>     "@material-ui/lab": "^4.0.0-alpha.57",
>     "@material-ui/styles": "latest",

Also, its noteworthy to say that as suggested on posts on the simialr issue, I tried to install materia-ui directly in my Heroku console using bash: "~ $ npm install @material-ui/core --save" and restarted the dynos after that but still the issue is not resolved

fwd="99.229.115.248" dyno=web.1 connect=0ms service=6ms status=200 bytes=1871 protocol=https
    2021-04-23T17:51:30.431853+00:00 app[web.1]: { Error: Cannot find module '@material-ui/core/styles'
    2021-04-23T17:51:30.431896+00:00 app[web.1]:     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    2021-04-23T17:51:30.431900+00:00 app[web.1]:     at Function.mod._resolveFilename (/app/node_modules/next/dist/build/webpack/require-hook.js:4:1784)
    2021-04-23T17:51:30.431900+00:00 app[web.1]:     at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    2021-04-23T17:51:30.431901+00:00 app[web.1]:     at Module.require (internal/modules/cjs/loader.js:692:17)
    2021-04-23T17:51:30.431901+00:00 app[web.1]:     at require (internal/modules/cjs/helpers.js:25:18)
    2021-04-23T17:51:30.431902+00:00 app[web.1]:     at Object.9Pu4 (/app/.next/server/pages/_app.js:410:18)
    2021-04-23T17:51:30.431902+00:00 app[web.1]:     at __webpack_require__ (/app/.next/server/pages/_app.js:23:31)
    2021-04-23T17:51:30.431902+00:00 app[web.1]:     at Module.1TCz (/app/.next/server/pages/_app.js:124:15)
    2021-04-23T17:51:30.431903+00:00 app[web.1]:     at __webpack_require__ (/app/.next/server/pages/_app.js:23:31)
    2021-04-23T17:51:30.431905+00:00 app[web.1]:     at Object.0 (/app/.next/server/pages/_app.js:99:18) code: 'MODULE_NOT_FOUND' }
    2021-04-23T17:52:30.703162+00:00 heroku[router]: at=info method=GET path="/" host=xigoapp.herokuapp.com request_id=f8b40d00-7f1d-44ff-afa8-e81f322aa600 
Alex2436
  • 11
  • 3

1 Answers1

0

Steps I did to resolve for a React JS app when deploying to Heroku were:

  1. uninstall dependencies for @material-ui/xyz and did a npm install again for the same with --save
  2. going to heroku portal you will find option to restart dynos or with CLI heroku restart command should work

References: npm i with --save heroku restart

Dharman
  • 30,962
  • 25
  • 85
  • 135
SHAHBAZ
  • 316
  • 3
  • 15