Search code examples
node.jsherokuexpress-4

Express 4 app - node ./bin/www X nodejs ./bin/www


I'm learning to work with node and express, I used express generator to setup a basic project and I pushed it to heroku, but I got this error in logs:

2015-12-27T16:29:01.478244+00:00 heroku[web.1]: Starting process with command `npm start`
2015-12-27T16:29:03.533736+00:00 app[web.1]: 
2015-12-27T16:29:03.522320+00:00 app[web.1]: 
2015-12-27T16:29:03.522335+00:00 app[web.1]: > [email protected] start /app
2015-12-27T16:29:03.522337+00:00 app[web.1]: > nodejs ./bin/www
2015-12-27T16:29:03.522337+00:00 app[web.1]: 
2015-12-27T16:29:03.526805+00:00 app[web.1]: sh: 1: nodejs: not found
2015-12-27T16:29:03.537910+00:00 app[web.1]: npm ERR! Linux 3.13.0-71-generic
2015-12-27T16:29:03.538285+00:00 app[web.1]: npm ERR! argv "/app/.heroku/node/bin/node" "/app/.heroku/node/bin/npm" "start"
2015-12-27T16:29:03.538482+00:00 app[web.1]: npm ERR! node v0.12.7
2015-12-27T16:29:03.540540+00:00 app[web.1]: npm ERR! npm  v2.11.3
2015-12-27T16:29:03.540543+00:00 app[web.1]: npm ERR! file sh
2015-12-27T16:29:03.540544+00:00 app[web.1]: npm ERR! code ELIFECYCLE
2015-12-27T16:29:03.540544+00:00 app[web.1]: npm ERR! errno ENOENT
2015-12-27T16:29:03.540545+00:00 app[web.1]: npm ERR! syscall spawn
2015-12-27T16:29:03.540547+00:00 app[web.1]: npm ERR! spawn ENOENT
2015-12-27T16:29:03.540546+00:00 app[web.1]: npm ERR! [email protected] start: `nodejs ./bin/www`
2015-12-27T16:29:03.540547+00:00 app[web.1]: npm ERR! 
2015-12-27T16:29:03.540548+00:00 app[web.1]: npm ERR! Failed at the [email protected] start script 'nodejs ./bin/www'.
2015-12-27T16:29:03.540549+00:00 app[web.1]: npm ERR! This is most likely a problem with the application-name package,
2015-12-27T16:29:03.540549+00:00 app[web.1]: npm ERR! not with npm itself.
2015-12-27T16:29:03.540550+00:00 app[web.1]: npm ERR! Tell the author that this fails on your system:
2015-12-27T16:29:03.540551+00:00 app[web.1]: npm ERR!     nodejs ./bin/www
2015-12-27T16:29:03.540552+00:00 app[web.1]: npm ERR! You can get their info via:
2015-12-27T16:29:03.540714+00:00 app[web.1]: npm ERR!     npm owner ls application-name
2015-12-27T16:29:03.540922+00:00 app[web.1]: npm ERR! There is likely additional logging output above.
2015-12-27T16:29:03.543464+00:00 app[web.1]: 
2015-12-27T16:29:03.543727+00:00 app[web.1]: npm ERR! Please include the following file with any support request:
2015-12-27T16:29:03.543869+00:00 app[web.1]: npm ERR!     /app/npm-debug.log
2015-12-27T16:29:04.374697+00:00 heroku[web.1]: Process exited with status 1
2015-12-27T16:29:04.392014+00:00 heroku[web.1]: State changed from starting to crashed

It started working when I changed this

"scripts": {
    "start": "nodejs ./bin/www"
  },

to this

"scripts": {
    "start": "node ./bin/www"
  },

but I don't know why, can anyone explain the difference between node and nodejs, and how this works with heroku.

Thx


Solution

  • Express generator creates a startup script that runs the command node ./bin/www which starts up your Express app by running the .bin/www JavaScript file. The problem was that there is/was no command labled nodejs, but there is one called node (which points to the node.js executable).

    Nodejs (node.js) is often called just node for short, typically so for command prompts.