Run a Node.js script as a daemon/service in the background
- Install pBackground globally via NPM.
npm install pbackground -g
Optionally: rename pbackground
to pBackground
: npm is unable to
handle the complexity of uppercase characters in a module name. Node.js on
Windows does not have this problem, so renaming the folder is not required
for you to use the module.
- Run your script using the node-bkg shortcut.
node-bkg your-script arguments...
There is currently no way to stop the script, other than to forcefully terminate the corresponding node.exe process.
This code is licensed under CC0 v1.0 Universal.