while deploying build in heroku ,its causing an dependency error ,does anyone have faced the same ? What would be the root cause ? Any idea to resolve this ?
The heroku build used to work before but now this error happens and its confusing really
remote: -----> Installing dependencies
remote: Installing node modules
remote: npm ERR! code ERESOLVE
remote: npm ERR! ERESOLVE could not resolve
remote: npm ERR!
remote: npm ERR! While resolving: next#12.1.6
remote: npm ERR! Found: react#16.14.0
remote: npm ERR! node_modules/react
remote: npm ERR! react#"^16.10.1" from the root project
remote: npm ERR! peer react#"^16.8.0" from #apollo/react-common#3.1.4
remote: npm ERR! node_modules/#apollo/react-common
remote: npm ERR! #apollo/react-common#"^3.1.4" from #apollo/react-components#3.1.5
remote: npm ERR! node_modules/#apollo/react-components
remote: npm ERR! #apollo/react-components#"^3.1.5" from #apollo/react-hoc#3.1.5
remote: npm ERR! node_modules/#apollo/react-hoc
remote: npm ERR! #apollo/react-hoc#"^3.1.5" from react-apollo#3.1.5
remote: npm ERR! node_modules/react-apollo
remote: npm ERR! 1 more (react-apollo)
remote: npm ERR! #apollo/react-common#"^3.1.4" from #apollo/react-hoc#3.1.5
remote: npm ERR! node_modules/#apollo/react-hoc
remote: npm ERR! #apollo/react-hoc#"^3.1.5" from react-apollo#3.1.5
remote: npm ERR! node_modules/react-apollo
remote: npm ERR! react-apollo#"^3.1.3" from the root project
remote: npm ERR! 3 more (#apollo/react-hooks, #apollo/react-ssr, react-apollo)
remote: npm ERR! 14 more (#apollo/react-components, #apollo/react-hoc, ...)
remote: npm ERR!
remote: npm ERR! Could not resolve dependency:
remote: npm ERR! peer react#"^17.0.2 || ^18.0.0-0" from next#12.1.6
remote: npm ERR! node_modules/next
remote: npm ERR! next#"^12.1.6" from the root project
remote: npm ERR! peer next#">= 5.1.0" from next-env#1.1.1
remote: npm ERR! node_modules/next-env
remote: npm ERR! next-env#"^1.1.0" from the root project
remote: npm ERR!
remote: npm ERR! Conflicting peer dependency: react#18.1.0
remote: npm ERR! node_modules/react
remote: npm ERR! peer react#"^17.0.2 || ^18.0.0-0" from next#12.1.6
remote: npm ERR! node_modules/next
remote: npm ERR! next#"^12.1.6" from the root project
remote: npm ERR! peer next#">= 5.1.0" from next-env#1.1.1
remote: npm ERR! node_modules/next-env
remote: npm ERR! next-env#"^1.1.0" from the root project
remote: npm ERR!
remote: npm ERR! Fix the upstream dependency conflict, or retry
remote: npm ERR! this command with --force, or --legacy-peer-deps
remote: npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
remote: npm ERR!
remote: npm ERR! See /tmp/npmcache.KnKS4/eresolve-report.txt for a full report.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.KnKS4/_logs/2022-06-03T12_47_36_545Z-debug-0.log
remote:
remote: -----> Build failed
add NPM_CONFIG_LEGACY_PEER_DEPS environmental variable to your Heroku app and set its value to true.
I had the same issue a few days ago (early June) while deploying my React app on Heroku as well. It seems the problem was caused by the npm version update. By default, Heroku uses the latest stable version of node and npm as the building engines, but it might lead to conflicting dependencies if you use a previous version of them.
So, if it works completely fine locally but this issue happens while deploying it on Heroku, here is the solution:
Use node --version and npm --version to check out the versions on your local instance, and then add them under engines section in your package.json file, like this (replace 16.0.0 and 7.10.0 with the versions you have):
"engines": {
"node": "16.0.0",
"npm": "7.10.0"
},
then redeploy the app on Heroku. Problem should be fixed.
Related
remote: -----> Installing dependencies
remote: Installing node modules
remote: npm ERR! code ERESOLVE
remote: npm ERR! ERESOLVE could not resolve
remote: npm ERR!
remote: npm ERR! While resolving: react-rss#2.0.1
remote: npm ERR! Found: react#18.2.0
remote: npm ERR! node_modules/react
remote: npm ERR! react#"^18.2.0" from the root project
remote: npm ERR! peer react#"^18.0.0" from #testing-library/react#13.4.0
remote: npm ERR! node_modules/#testing-library/react
remote: npm ERR! #testing-library/react#"^13.4.0" from the root project
remote: npm ERR! 4 more (react-dom, react-router, react-router-dom, react-scripts)
remote: npm ERR!
remote: npm ERR! Could not resolve dependency:
remote: npm ERR! peer react#"^16.13.1" from react-rss#2.0.1
remote: npm ERR! node_modules/react-rss
remote: npm ERR! react-rss#"^2.0.1" from the root project
remote: npm ERR!
remote: npm ERR! Conflicting peer dependency: react#16.14.0
remote: npm ERR! node_modules/react
remote: npm ERR! peer react#"^16.13.1" from react-rss#2.0.1
remote: npm ERR! node_modules/react-rss
remote: npm ERR! react-rss#"^2.0.1" from the root project
remote: npm ERR!
remote: npm ERR! Fix the upstream dependency conflict, or retry
remote: npm ERR! this command with --force, or --legacy-peer-deps
remote: npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
remote: npm ERR!
remote: npm ERR! See /tmp/npmcache.zVSUf/eresolve-report.txt for a full report.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.zVSUf/_logs/2022-11-03T19_15_38_788Z-debug-0.log
remote:
remote: -----> Build failed
remote:
remote: We're sorry this build is failing! You can troubleshoot common issues here:
remote: https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote: Some possible problems:
remote:
remote: - Node version not specified in package.json
remote: https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
remote:
remote: Love,
remote: Heroku
remote:
remote: ! Push rejected, failed to compile Node.js app.
remote:
remote: ! Push failed
remote: !
remote: ! ## Warning - The same version of this code has already been built: ea132e7d82ff4a3fe3121b0858e49a2c8336bec0
remote: !
remote: ! We have detected that you have triggered a build from source code with version ea132e7d82ff4a3fe3121b0858e49a2c8336bec0
remote: ! at least twice. One common cause of this behavior is attempting to deploy code from a different branch.
remote: !
remote: ! If you are developing on a branch and deploying via git you must run:
remote: !
remote: ! git push heroku <branchname>:main
remote: !
remote: ! This article goes into details on the behavior:
remote: ! https://devcenter.heroku.com/articles/duplicate-build-version
remote:
remote: Verifying deploy...
remote:
remote: ! Push rejected to tb-work-hub.
remote:
To https://git.heroku.com/tb-work-hub.git
! [remote rejected] master -> master (pre-receive hook declined)
I don't understand this. It was working just fine yesterday. I'm guessing it's to do with some dependencies I was trying to work with?
If there isn't a clean solution, is there a good way to restore my app without having to start fresh, reinstall everything and copy-paste the src?
Tried: npm uninstall react-rss
Go to the app in Heroku -> settings -> Reveal Config Vars
Add a new config var with the key: NPM_CONFIG_LEGACY_PEER_DEPS and value true, and then redeploy.
(Heroku Shopify Application Error 'npm ERR! ERESOLVE unable to resolve dependency tree')
I hope it works.
I'm running the follow command to push my app on Heroku 'git push heroku master', but it returns:
-----> Installing binaries
engines.node (package.json): 16.13.2
engines.npm (package.json): 8.1.2
Resolving node version 16.13.2...
Downloading and installing node 16.13.2...
npm 8.1.2 already installed with node
-----> 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: paper-kit-2-angular#1.4.0
npm ERR! Found: zone.js#0.11.3
npm ERR! node_modules/zone.js
npm ERR! zone.js#"0.11.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer zone.js#"~0.10.3" from #angular/core#11.0.4
npm ERR! node_modules/#angular/core
npm ERR! #angular/core#"11.0.4" from the root project
npm ERR! peer #angular/core#"11.0.4" from #angular/common#11.0.4
npm ERR! node_modules/#angular/common
npm ERR! #angular/common#"11.0.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.GEG9a/eresolve-report.txt for a full report.
Can anyone help me?
Add your local "node" and "npm" version to package.json. For example I did:
"engines": {
"node": "16.15.1",
"npm": "8.5.5"
},
Apparently for me the "knex" module that I use is not compatible with newer npm (I am not sure).
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.
I'm having trouble deploying from my server sub-directory. I've been searching around all of Stack Overflow and none of the answers were able to help me fix this. I made use of npm --prefix as well as git subtree push --prefix server heroku master. I have listed below my file structure, package.json, and Heroku logs.
File Structure:
- client
- server
package.json snippet:
"heroku-postbuild": "NPM_CONFIG_PRODUCTION=false npm install --prefix ../client && npm run build --prefix ../client"
Heroku Logs:
remote: npm ERR! code ENOENT
remote: npm ERR! syscall open
remote: npm ERR! path /tmp/client/package.json
remote: npm ERR! errno -2
remote: npm ERR! enoent ENOENT: no such file or directory, open '/tmp/client/package.json'
remote: npm ERR! enoent This is related to npm not being able to find a file.
remote: npm ERR! enoent
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /tmp/npmcache.x8Dnr/_logs/2021-01-23T22_37_55_270Z-debug.log
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 254
remote: npm ERR! server#1.0.0 heroku-postbuild: `NPM_CONFIG_PRODUCTION=false npm install --prefix ../client && npm run build --prefix ../client`
remote: npm ERR! Exit status 254
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?