If you are building a Node.js app and have been deploying your app to Heroku and testing it there all along, you might be surprised to see this error next time you try pushing your code to Heroku with the following command...
git push heroku master
The error you might see is:
Push rejected, failed to compile Node.js app
The full error may look like this:
Counting objects: 14, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (8/8), done.
Writing objects: 100% (9/9), 972 bytes | 0 bytes/s, done.
Total 9 (delta 4), reused 0 (delta 0)
remote: Compressing source files... done.
remote: Building source:
remote: -----> Removing .DS_Store files
remote: -----> Node.js app detected
remote: -----> Resetting git environment
remote: ! Push rejected, failed to compile Node.js app
remote: Verifying deploy...
remote: ! Push rejected to project.
! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/project.git'
While this is a bit of a generic error and can be caused by several different issues, one of the reasons I face it is that the npm cache is stale, so a very easy way to resolve such an issue is by cleaning your npm cache simply by issuing this command:
npm cache clean
If you require administrative privileges to run this command, adding sudo in front of the command will help, like this...
sudo npm cache clean
Hope this helps...
Until next time,