0

I'm attempting to deploy from Github my project, but I run into errors, which are related to the installation of the modules.

I have ran into some questions about the topic, and I attempted adding to the package.json file the following lines:

"engines": {
  "node": "<=14.x.x",
  "npm": "<=6.x.x"
} 

But still, when I try to click 'Deploy', I get the following error:

-----> Building on the Heroku-20 stack
-----> Using buildpack: heroku/nodejs
-----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_PRODUCTION=false
       NPM_CONFIG_LOGLEVEL=error
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 18.x...
       Downloading and installing node 18.12.1...
       Using default npm version: 8.19.2
       
-----> Restoring cache
       Cached directories were not restored due to a change in version of node, npm, yarn or stack
       Module installation may take longer for this build
       
-----> Installing dependencies
       Installing node modules
       npm ERR! code ERESOLVE
       npm ERR! ERESOLVE could not resolve
       npm ERR! 
       npm ERR! While resolving: @material-ui/core@4.12.4
       npm ERR! Found: react@18.2.0
       npm ERR! node_modules/react
       npm ERR!   react@"^18.2.0" from the root project
       npm ERR!   peer react@">=16.8.0" from @emotion/react@11.10.4
       npm ERR!   node_modules/@emotion/react
       npm ERR!     @emotion/react@"^11.10.4" from the root project
       npm ERR!     peer @emotion/react@"^11.0.0-rc.0" from @emotion/styled@11.10.4
       npm ERR!     node_modules/@emotion/styled
       npm ERR!       @emotion/styled@"^11.10.4" from the root project
       npm ERR!       3 more (@mui/material, @mui/styled-engine, @mui/system)
       npm ERR!     3 more (@mui/material, @mui/styled-engine, @mui/system)
       npm ERR!   15 more (@emotion/styled, ...)
       npm ERR! 
       npm ERR! Could not resolve dependency:
       npm ERR! peer react@"^16.8.0 || ^17.0.0" from @material-ui/core@4.12.4
       npm ERR! node_modules/@material-ui/core
       npm ERR!   @material-ui/core@"^4.12.4" from the root project
       npm ERR! 
       npm ERR! Conflicting peer dependency: react@17.0.2
       npm ERR! node_modules/react
       npm ERR!   peer react@"^16.8.0 || ^17.0.0" from @material-ui/core@4.12.4
       npm ERR!   node_modules/@material-ui/core
       npm ERR!     @material-ui/core@"^4.12.4" from the root project
       npm ERR! 
       npm ERR! Fix the upstream dependency conflict, or retry
       npm ERR! this command with --force, or --legacy-peer-deps
       npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
       npm ERR! 
       npm ERR! See /tmp/npmcache.q24sn/eresolve-report.txt for a full report.
       
       npm ERR! A complete log of this run can be found in:
       npm ERR!     /tmp/npmcache.q24sn/_logs/2022-11-07T15_01_32_484Z-debug-0.log
-----> Build failed
       
       We're sorry this build is failing! You can troubleshoot common issues here:
       https://devcenter.heroku.com/articles/troubleshooting-node-deploys
       
       Some possible problems:
       
       - Node version not specified in package.json
         https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
       
       Love,
       Heroku
       
 !     Push rejected, failed to compile Node.js app.
 !     Push failed

Did anyone run across this issue? The only hint I have is that when I needed to install modules of material-ui in my project by using npm install, I had to add the following flags: --legacy-peer-deps

how can I choose the commands Heroku will run on Deploy, so I can add the --legacy-peer-deps in order to check whether that's the issue or not? Is it possible to do such thing?

I will just emphasize that I'm speaking about Heroku's deployment, not me installing it through my Terminal locally.

Thanks for any attempt to help!

dani_l_n
  • 376
  • 1
  • 11
  • 1
    "The only hint I have is that when I needed to install modules of material-ui in my project by using npm install, I had to add the following flags: `--legacy-peer-deps`"—you shouldn't be doing that in the first place. Fix your dependencies so you can install _without_ `--legacy-peer-deps` locally, then deploy to Heroku. Though if you _really_ want to ignore that advice, see https://stackoverflow.com/q/74236185/354577. – ChrisGPT was on strike Nov 07 '22 at 21:00

0 Answers0