Push rejected, failed to compile Node.js app heroku

I am working in ReactJS and I am trying to deploy my project on Heroku server. At that time I have found same error like this:

Push rejected, failed to compile Node.js app.

enter image description here

Solution is:

If you use yarn:

git rm yarn.lock

git push heroku master

If you use npm:

git rm package-lock.json

git push heroku master


Adding node_modules may be easy but not the correct approach here. Instead do git push -f heroku master in order to FORCE push your updates telling heroku to overwrite any pre-existing node_modules. This way your git repo is not bogged down with node libs.


The easiest way to make this work is to add node_modules to your .gitignore. Lots more info here: Fail to deploy node.js application to heroku