Strapi + Heroku deployment failed:npm ERR! code ERESOLVE - heroku

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: drkang-strapi#0.1.0
npm ERR! Found: knex#0.19.5
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 strapi-connector-bookshelf#3.4.6
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.

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"
}

In my case .npmrc solved this,
create .npmrc in the root of the project and allow legacy peer dependencies
legacy-peer-deps=true

Jryke's way solved my problem:
I added these lines to package.json and the problem fixed:
"engines": {
"node": "16.x",
"npm": "8.5.5"
},
And again thanks to Jryke :-) yes I use "knex" module in my code and yes I use "heroku" also.

Related

Heroku: Build Failed

-----> 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): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 14.x...
Downloading and installing node 14.16.0...
Using default npm version: 6.14.11
-----> 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
Prebuild detected (node_modules already exists)
Rebuilding any native modules
> canvas#2.6.1 install /tmp/build_dc388f20_/node_modules/canvas
> node-pre-gyp install --fallback-to-build
sh: 1: node-pre-gyp: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! canvas#2.6.1 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the canvas#2.6.1 install 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! /tmp/npmcache.40jbb/_logs/2021-03-05T17_30_09_270Z-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:
- node_modules checked into source control
https://devcenter.heroku.com/articles/node-best-practices#only-git-the-important-bits
- 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
How do i fix this?

node-canvas on Heroku

I have a discord.js bot and it runs on Heroku.
I added canvas just now, and now the bot is failing to build.
This is the log:
-----> Installing dependencies
Prebuild detected (node_modules already exists)
Rebuilding any native modules
> canvas#2.6.1 install /tmp/build_c8ad4f45_/node_modules/canvas
> node-pre-gyp install --fallback-to-build
sh: 1: node-pre-gyp: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! canvas#2.6.1 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the canvas#2.6.1 install 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! /tmp/npmcache.uZg6i/_logs/2021-01-01T17_53_37_239Z-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:
- node_modules checked into source control
https://devcenter.heroku.com/articles/node-best-practices#only-git-the-important-bits
- 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
I already installed node-pre-gyp as the log suggested, and nothing changed.
Here is package.json:
{
"dependencies": {
"canvas": "^2.6.1",
"discord.js": "^12.4.1",
"dotenv": "^8.2.0",
"firebase": "^8.1.1",
"firebase-admin": "^9.4.1",
"node-pre-gyp": "^0.11.0"
}
}
Does anyone know a solution to this?

Error "node_modules checked into source control" when trying to run a discord bot

When i try to run the bot in Heroku, it keeps giving me the same error and not turning the bot on. How would i go on to fix this issue? All the files and node modules are already installed in the github repository
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NODE_ENV=production
NODE_MODULES_CACHE=true
NODE_VERBOSE=false
-----> Installing binaries
engines.node (package.json): unspecified
engines.npm (package.json): unspecified (use default)
Resolving node version 12.x...
Downloading and installing node 12.19.1...
Using default npm version: 6.14.8
-----> Installing dependencies
Prebuild detected (node_modules already exists)
Rebuilding any native modules
> #discordjs/opus#0.3.2 install /tmp/build_8234188f_/node_modules/#discordjs/opus
> node-pre-gyp install --fallback-to-build
sh: 1: node-pre-gyp: Permission denied
npm ERR! code ELIFECYCLE
npm ERR! errno 126
npm ERR! #discordjs/opus#0.3.2 install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 126
npm ERR!
npm ERR! Failed at the #discordjs/opus#0.3.2 install 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! /tmp/npmcache.tAPfy/_logs/2020-11-22T22_42_39_963Z-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:
- node_modules checked into source control
https://devcenter.heroku.com/articles/node-best-practices#only-git-the-important-bits
Love,
Heroku
! Push rejected, failed to compile Node.js app.
! Push failed

Building of app during app deployment fails in Heroku

I tried deploying an app in Heroku (the same one I tried asking about here), but although it deployed, I keep on getting the wrong output. So I deleted the deployed app (I deployed it using Heroku's website) and tried to deploy it by using Heroku CLI on cmd instead. but then suddenly the app won't deploy. I tried to deploy it using the website again, but it still won't deploy and keep on showing this error message
-----> Node.js app detected
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NPM_CONFIG_PRODUCTION=true
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=true
-----> Installing binaries
engines.node (package.json): 4.1.1
engines.npm (package.json): unspecified (use default)
Resolving node version 4.1.1...
Downloading and installing node 4.1.1...
Using default npm version: 2.14.4
-----> Restoring cache
Skipping cache restore (not-found)
-----> Building dependencies
Installing node modules (package.json)
npm ERR! install Couldn't read dependencies
npm ERR! Linux 4.14.12-041412-generic
npm ERR! argv "/tmp/build_fd784069b3690d9546dfaea15e0e3251/digracesion-make-sandwich-0fe3e02/.heroku/node/bin/node" "/tmp/build_fd784069b3690d9546dfaea15e0e3251/digracesion-make-sandwich-0fe3e02/.heroku/node/bin/npm" "install" "--unsafe-perm" "--userconfig" "/tmp/build_fd784069b3690d9546dfaea15e0e3251/digracesion-make-sandwich-0fe3e02/.npmrc"
npm ERR! node v4.1.1
npm ERR! npm v2.14.4
npm ERR! Invalid name: "Make Sandwich App"
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR! <https://github.com/npm/npm/issues>
npm ERR! Please include the following file with any support request:
npm ERR! /tmp/build_fd784069b3690d9546dfaea15e0e3251/digracesion-make-sandwich-0fe3e02/npm-debug.log
-----> Build failed
removed the capital letters and spaces in the name field like #Syed said and changed it to something like make-sandwich.
when this didn't worked, i check the files in the repository and realized that not all files were committed properly by trying the command
git status
so i committed all of the changes using these:
git add .
git commit -m "commit comment here"
and then pushed the changes with the use of
git push heroku master

Issue with deployment of sails.js app on Heroku - npm error - package: sailshq/body-parser

To start, current configuration - Development machine:
Node version: 8.4.0
Npm: 5.3.0 (comes with 8.4)
Sails: ~0.12.13
Source control system: Github
Deployment host: Heroku
I followed following guide: https://vort3x.me/sailsjs-heroku/ (except the heroku git part, working with github)
But I am rather stuck when I press deploy in Heroku, the following happens:
-----> Creating runtime environment
NPM_CONFIG_LOGLEVEL=error
NPM_CONFIG_PRODUCTION=true
NODE_VERBOSE=false
NODE_ENV=production
NODE_MODULES_CACHE=false
-----> Installing binaries
engines.node (package.json): 8.4.0
engines.npm (package.json): unspecified (use default)
Resolving node version 8.4.0...
Downloading and installing node 8.4.0...
Detected package-lock.json: defaulting npm to version 5.x.x
Bootstrapping npm 5.x.x (replacing 5.3.0)...
npm 5.3.0 installed
-----> Restoring cache
Skipping cache restore (disabled)
-----> Building dependencies
Installing node modules (package.json + package-lock)
npm ERR! path /tmp/build_7f8d8515578971e692c2e6a35e1006d2/bdemolder-boardgamenights-f5eda42/node_modules/.staging/sails-fec6f6e5/node_modules/#sailshq/body-parser
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/tmp/build_7f8d8515578971e692c2e6a35e1006d2/bdemolder-boardgamenights-f5eda42/node_modules/.staging/sails-fec6f6e5/node_modules/#sailshq/body-parser' -> '/tmp/build_7f8d8515578971e692c2e6a35e1006d2/bdemolder-boardgamenights-f5eda42/node_modules/.staging/#sailshq/body-parser-9ed21a9f'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR! /app/.npm/_logs/2017-08-22T20_43_13_796Z-debug.log
-----> Build failed
And frankly I have no idea what to do about this, I thought first it was because I forgot to say engine 'node: 8.4.0' and that my cache was corrupted, so I tried disabling cache, but nothing so far.
It says to rename, but I have no control over dependencies within Sails.js?
Probably doing something wrong...
Thx and kind regards
PS: I will keep looking myself and answer if I find anything.
Just remove package-lock.json, commit and push to Heroku !

Resources