Create a gist now

Instantly share code, notes, and snippets.

@dceejay /nssm.md
Last active Jul 5, 2017

What would you like to do?
Running Node-RED as a service on Windows using NSSM

Running Node-RED as a service on Windows using NSSM

These instructions assume you installed Node-RED from an administrator enabled command prompt using the npm install -g node-red command to do so.

As an administrator, install nssm from https://nssm.cc/download

And then from the directory where you installed nssm, run the commands

mkdir c:\temp
nssm install Node-RED "c:\Users\\"%USERNAME%"\AppData\Roaming\npm\node-red.cmd"
nssm set Node-RED AppDirectory "c:\Users\\"%USERNAME%"\.node-red"
nssm set Node-RED AppParameters "-u c:\Users\\"%USERNAME%"\.node-red > c:\temp\node-red.log"
nssm set Node-RED Description "A wiring tool for the Internet of Things"

You can edit the service using the GUI to the configuration, add extra parameters, etc.

nssm edit Node-RED

The log will be written to c:\temp\node-red.log (see line 3)

For further options read the nssm usage page.

natcl commented Jan 21, 2016

For anybody having troubles with this, make sure you create the C:\temp directory before running the service.

bloigge commented Apr 13, 2016

Another way for autostarting NodeRed in PM2 as a Serivce in Windows:

Everything in command-line as Admin:

Install node-red

npm install -g node-red

Install pm2

npm install pm2 -g

Install and config pm2-windows-startup package :

npm install pm2-windows-startup -g
pm2-startup install
pm2 save

Locate the Node-Red red.js File and add it to pm2:

pm2 start C:\Users\<USER-NAME>\AppData\Roaming\npm\node_modules\node-red\red.js --save

alex3305 commented Dec 3, 2016

Note: Running this from a Powershell prompt will not work. Escaping of quotes will fail and the commands will all get borked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment