Node-windows Library
Using node-windows (JavaScript approach)
node-windows (JavaScript approach)Step 1: Install node-windows
node-windows npm install -g node-windowsnpm install node-windowsStep 2: Create a Service Script (e.g., service.js)
service.js)const Service = require('node-windows').Service;
// Create a new service object
const svc = new Service({
name: 'My Node App',
description: 'Node.js App running as a service',
script: 'C:\\myapp\\app.js',
nodeOptions: [
'--harmony',
'--max_old_space_size=4096'
]
});
// Listen for the "install" event
svc.on('install', () => {
console.log('Service installed');
svc.start();
});
svc.install();
Step 3: Run the Script to Install the Service
Step 4: Check Services
Last updated