Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Fail to deploy node.js application to heroku

Tags:

node.js

heroku

I am trying to deploy a simple node.js express-based application to heroku, something which is apparently very basic: https://devcenter.heroku.com/articles/nodejs

Here is my package.json:

{
  "name": "cours-lic3-blois",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node app"
  },
  "dependencies": {
    "express": "*",
    "ejs": "*",
    "github-flavored-markdown": "*",
    "less-middleware": "*"
  },
  "engines": {
    "node": "0.8.8",
    "npm": "1.1.65"
  }
}

When I git push heroku master I got the following trace:

 -----> Heroku receiving push
 -----> Node.js app detected
 -----> Resolving engine versions
        Using Node.js version: 0.8.8
        Using npm version: 1.1.65
 -----> Fetching Node.js binaries
 -----> Vendoring node into slug
 -----> Installing dependencies with npm
        npm ERR! Error: ENOENT, chmod '/tmp/build_1suuxlhd9s8n6/node_modules/express/bin/express'
        npm ERR! If you need help, you may report this log at:
        npm ERR!     <http://github.com/isaacs/npm/issues>
        npm ERR! or email it to:
        npm ERR!     <[email protected]>

        npm ERR! System Linux 2.6.32-348-ec2
        npm ERR! command "/tmp/node-node-tonf/bin/node" "/tmp/node-npm-NG88/cli.js" "rebuild"
        npm ERR! cwd /tmp/build_1suuxlhd9s8n6
        npm ERR! node -v v0.8.8
        npm ERR! npm -v 1.1.65
        npm ERR! path /tmp/build_1suuxlhd9s8n6/node_modules/express/bin/express
        npm ERR! code ENOENT
        npm ERR! errno 34
        npm ERR!
        npm ERR! Additional logging details can be found in:
        npm ERR!     /tmp/build_1suuxlhd9s8n6/npm-debug.log
        npm ERR! not ok code 0
  !     Failed to rebuild dependencies with npm
  !     Heroku push rejected, failed to compile Node.js app

 To [email protected]:fast-everglades-2007.git
  ! [remote rejected] master -> master (pre-receive hook declined)
 error: failed to push some refs to '[email protected]:fast-everglades-2007.git'

I tried to tweak various versions in my package.json but to no avail. I am developing on windows and it might be possible this ENOENT issue is due to some filemode issue.

like image 832
insitu Avatar asked Nov 10 '12 10:11

insitu


People also ask

Why my Heroku app is not working?

There are some errors which only occur when the app is rebooting so you will need to restart the app to see these log messages appear. For most apps, we also recommend enabling one of the free logging addons from https://elements.heroku.com/addons#logging to make sure that your historical log data is being saved.

Does Heroku support node JS?

Heroku Node. js support will only be applied when the application has a package. json file in the root directory.

What node version does Heroku use?

js release schedule below, Heroku's currently supported Node. js versions are 14. x , 16. x , and 18.


2 Answers

I got this fixed by:

  • Making sure Procfile is committed into git

  • Removing the node_modules/ folder and committing that into git (git rm -r node_modules/)

Afterwards, I did the git push heroku master then the error disappeared.

like image 193
Arbie Samong Avatar answered Oct 23 '22 10:10

Arbie Samong


I had this problem, and it was because:

  1. I keep node_modules in version control
  2. I had bin in my .gitignore file

npm was attempting to chmod express/bin/express, but due to my .gitignore this file wasn't in git and thus was not being cloned during the deploy, so it failed. I didn't notice it because a local npm install would create the bin/express file as usual.

Removing bin from .gitignore and committing the missing files solved the problem for me.

like image 28
clarkdave Avatar answered Oct 23 '22 10:10

clarkdave