0
votes

I'm following this tutorial to deploy the Strapi app to Heroku.

I have set up to auto-deploy from my Github repo.

After pushing to Github, I get the notification of build failure with the following message.

build log

-----> Building on the Heroku-20 stack
-----> 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):  >=10.16.0 <=14.x.x
       engines.npm (package.json):   >=6.0.0
       
       Resolving node version >=10.16.0 <=14.x.x...
       Downloading and installing node 14.15.4...
       Bootstrapping npm >=6.0.0 (replacing 6.14.10)...
       npm >=6.0.0 installed
       
-----> Installing dependencies
       Installing node modules (package.json)
       npm ERR! code ERESOLVE
       npm ERR! ERESOLVE unable to resolve dependency tree
       npm ERR! 
       npm ERR! While resolving: [email protected]
       npm ERR! Found: [email protected]
       npm ERR! node_modules/knex
       npm ERR!   knex@"<0.20.0" from the root project
       npm ERR! 
       npm ERR! Could not resolve dependency:
       npm ERR! peer knex@"^0.20.0" from [email protected]
       npm ERR! node_modules/strapi-connector-bookshelf
       npm ERR!   strapi-connector-bookshelf@"3.4.6" 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.9OnCF/eresolve-report.txt for a full report.
       
       npm ERR! A complete log of this run can be found in:
       npm ERR!     /tmp/npmcache.9OnCF/_logs/2021-02-04T02_14_54_807Z-debug.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:
       
       - Dangerous semver range (>) in engines.node
         https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
       
       Love,
       Heroku
       
 !     Push rejected, failed to compile Node.js app.
 !     Push failed

What should I do here? Any help would be appreciated.

1

1 Answers

4
votes

I had the same issue today. It appears to me that the problem has to do with the version of knex not being compatible with the version of nodejs. After looking into it more, Strapi isn't compatible with nodejs over v.14 or npm over v.6 (Heroku was trying to build my Strapi app with node v.15). To resolve it, I updated the package.json file to make sure that Heroku uses the versions that are compatible. Here is what I added, it worked for me and I hope it works for you.

In the package.json file, update the versions of node and npm like this:

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