Home > Enterprise >  Heroku Deploy: Facing build error after updating NextJS
Heroku Deploy: Facing build error after updating NextJS

Time:01-13

I had updated NextJS and after updating it and pushing changes on Heroku I'm encountering an Build error, locally everything is working fine and I could even install all the NPMs without using -force or --legacy-peer-deps commands. But still encountering package issues while deploying.

-----> Building on the Heroku-22 stack
-----> Using buildpack: heroku/nodejs
-----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       
-----> Installing binaries
       engines.node (package.json):  16.15.0
       engines.npm (package.json):   8.5.5
       
       Resolving node version 16.15.0...
       Downloading and installing node 16.15.0...
       npm 8.5.5 already installed with node
       
-----> Restoring cache
       - npm cache
       
-----> Installing dependencies
       Installing node modules
       npm ERR! code ERESOLVE
       npm ERR! ERESOLVE could not resolve
       npm ERR! 
       npm ERR! While resolving: isxy-prototype-next-scratch@undefined
       npm ERR! Found: [email protected]
       npm ERR! node_modules/next
       npm ERR!   next@"13.1.1" from the root project
       npm ERR! 
       npm ERR! Could not resolve dependency:
       npm ERR! next@"13.1.1" from the root project
       npm ERR! 
       npm ERR! Conflicting peer dependency: [email protected]
       npm ERR! node_modules/react
       npm ERR!   peer react@"^18.2.0" from [email protected]
       npm ERR!   node_modules/next
       npm ERR!     next@"13.1.1" 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.IAUlC/eresolve-report.txt for a full report.
       
       npm ERR! A complete log of this run can be found in:
       npm ERR!     /tmp/npmcache.IAUlC/_logs/2023-01-11T06_56_44_322Z-debug-0.log
-----> Build failed

I had tried deleting all the node modules, cleaning the cache and then I tried reinstalling npms. But still nothing could fix this issue on server

CodePudding user response:

Please try to define engines in your package.json file

"engines": {
    "node": "16.x",
    "npm": "8.5.5"
},

CodePudding user response:

The Heroku server expects package-lock.json file present on the server to be same as what will be deployed. So, I deleted the file on the server and pushed it again (what was available locally) and everything worked fine.

  • Related