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.
Hey, I setup the PM2 service described above by @bloggie. Thank you BTW for your solution!
When I was running from the command prompt and I went to safely shut down ie.. ctrl+C, sometimes it would take a good few seconds before it shut down or I'd even have to hit ctrl+c a couple of times before it shut down.
When I stop the service using:
cmd /k pm2 stop C:\Users\ubiquitous\AppData\Roaming\npm\node_modules\node-red\red.js pause
It stops the service almost instantly every single time.
I'm just wondering if the way I am stopping the service is the right way for it to be "safe"