10

I want to create a nodejs service, so that the node server starts as my computer starts, and i do not have to keep the command prompt open all the time. I m tryng to achieve this by using NSSM.

Here is the command to create the service:

nssm.exe install jewel-server C:\Program Files\nodejs\node.exe D:\jewel\server.js

Run service:

net start jewel-server

But this doesnt work and give this error:

The jewel-server service is starting.
The jewel-server service could not be started.

A service specific error occured: 3.

I checked error code 3 means the path is not correct but the is path correct. Can you tell what i am doing wrong, or is there any other open source & more reliable alternative to NSSM

Version:

NSSM
version: 2.24
Windows-7 64bit

3 Answers 3

14

The way parameters were passed was not correct, So used the NSSM GUI to set the parametes:

Open GUI: nssm.exe install jewel-server

Once the GUI is open give in the following values.

Path: C:\Program Files\nodejs\node.exe
Arguments: D:\jewel\server.js
Press Install service

Done! You can start the service now.

8

According to http://nssm.cc/commands You may want to try the following commands.

nssm install jewel-server "C:\Program Files\nodejs\node.exe"
nssm set jewel-server AppDirectory "D:\jewel"
nssm set jewel-server AppParameters server.js
nssm start jewel-server

You may check the nssm by

nssm edit jewel-server 
nssm status jewel-server

Hope this will help.

1
  • Above solution works fine if you want the program to be run as node server.js . However , if it needs to run as npm start then suggestion is to create a .bat file that includes npm start in it and make the location of this .bat file the path to use in NSSM
    – rugby2312
    Commented Oct 17, 2023 at 9:03
5

It's because of the space in the "Program Files". All you have to do is put it in quotes like so:

nssm.exe install jewel-server "C:\Program Files\nodejs\node.exe" D:\jewel\server.js

Not the answer you're looking for? Browse other questions tagged or ask your own question.