Watch the video:
Timestamps:
0:00 - Explanation
0:20 - Installing node-windows
0:33 - Creating service script for a node project
1:26 - Installing node project as Windows service
2:50 - Uninstall node service on Windows
Want a Node script to run 24/7 in the background of your computer, without needing to remember to start it? Don’t want any visible signs that it’s running? Well, you can set up your project to run as a Windows Service in the background, with the automatic starting ability, as well as other perks of having it run as a Windows Service.
Code:
—————
var Service = require(’node-windows’).Service;
var svc = new Service({
name:‘Service name’,
description: ‘Node.js service description goes here.’,
script: ‘C:\path\test.js’
});
svc.on(‘install’,function(){
svc.start();
});