Push rejected, failed to compile Node.js app heroku

When I tried to push my nodejs application on heroku using git push heroku master , I got the following:

 Counting objects: 975, done. Delta compression using up to 2 threads. Compressing objects: 100% (862/862), done. Writing objects: 100% (975/975), 3.74 MiB | 80.00 KiB/s, done. Total 975 (delta 70), reused 0 (delta 0) -----> Node.js app detected -----> Resolving engine versions Using Node.js version: 0.10.15 Using npm version: 1.3.3 -----> Fetching Node.js binaries -----> Vendoring node into slug -----> Installing dependencies with npm npm ERR! install Couldn't read dependencies ! Push rejected, failed to compile Node.js app To git@heroku.com :hidden-reaches-9268.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to ' git@heroku.com :hidden-reaches-9268.git' 

And this is my .json package:

 { "name": "fnBoard", "version": "0.0.1", "private": true, "scripts": { "start": "node server.js" }, "dependencies": { "socket.io": "0.9.x" }, "engines": { "node": "0.10.x", "npm": "1.3.x" } } 

There are a bunch of bugs inside, and I have no idea why this is happening. please help. -Thanks

+11
git heroku
source share
6 answers

The easiest way to make this work is to add node_modules to your .gitignore. More info here: Failed to deploy node.js application for heroku

+10
source share

I work in ReactJS and am trying to deploy my project on a Heroku server. At that time, I found the same error like this:

Push rejected, failed to compile Node.js. application

enter image description here

Decision:

If you use yarn:

git rm yarn.lock

git push hero master

If you are using npm:

git rm package-lock.json

git push hero master

+10
source share

Adding node_modules may be a simple but not the right approach. Instead, git push -f heroku master so that FORCE pushes your updates telling the hero to overwrite any pre-existing node_modules. This way your git repository is not linked to node libs.

+4
source share

Try installing the heroku-postbuild script for your package.json and be sure to enable your engines.

 "scripts": { "heroku-postbuild": "npm run build" }, "engines": { "npm": "5.6.0", "node": "8.10.0" } 

I would try to avoid pushing anything at all costs, be it github or heroku.

0
source share

I solved it.
I got the same error:

"Push rejected, failed to compile Node.js app"

but my journal complained about this unknown option:

 '--target' 

I solved this problem in my package.json and found the following line of code:

 "postinstall": "ng build --aot --target=production" 

I removed --target=production .

On my terminal:
I again sent $ git commit -m 'anything here'
then $ git push heroku master
And I fixed it.

0
source share

I had the same problem, the problem was with git add. I forgot to add node_modules files. I closed the terminal and ran the set of commands in the Getting Started with Heroku and NodeJs [1] section again. The application was successfully pushed onto the stack.

0
source share

All Articles