Blog Archives

Node.js As a Service on Windows

This week I am going to outline the difficulties I have in getting my app running as a service on windows.

Normally I would start up my server either by calling “coffee app.coffee” or “npm start”. If you look around at the blogs and posts about this you’ll find that all of them refer to running the service via “node app.js”. Which just plain won’t work for me.

Beforehand I’ve used nssm, so I decided to give it a go again, I settled for getting it to run “npm start”.

Steps!

  1. Figure out the location of your node.js installation (node.exe), for me it was “C:\Program Files\nodejs\node.exe”.
  2. Fire up nssm in the add service mode.
  3. Enter in your node installation for Application Path.
  4. Enter in the directory of your project in Startup directory.
  5. In Arguments put in the quoted location of the npm-cli.js file and then “start” (with quotes). This should be relative to your node installation, for me it’s “C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js”.
    In total the Arguments field should look like:

    "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "start"
  6. Hit save and your service should run as if you called “npm start”!

2014-08-06_1445