Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
desktop-service
Advanced tools
Run Node.js scripts as native services on Windows, Mac OS and Linux.
var Service = require('desktop-service');
var svc = new Service({
name: 'Sample Service',
description: 'Sample service running Node.js script.',
script: require('path').join(__dirname, 'service.js'),
});
svc.on('install', function () {
svc.start();
});
svc.install();
After the installation the service will be listed like any other service in the service management utility of the OS.
Sometimes you may want to provide a service with static data, passed in on creation of the service. You can do this by setting environment variables in the service config, as shown below:
var svc = new Service({
name: 'Sample service',
description: 'Sample service running Node.js script.',
script: require('path').join(__dirname, 'service.js'),
env: [
{
name: 'HOME',
value: process.env['USERPROFILE'], // service is now able to access the user who created its home directory
},
{
name: 'TEMP',
value: path.join(process.env['USERPROFILE'], '/temp'), // use a temp directory in user's home directory
},
],
});
var Service = require('desktop-service');
var svc = new Service({
name: 'Sample Service',
script: require('path').join(__dirname, 'service.js'),
});
svc.on('uninstall', function () {
console.log('Uninstall complete.');
console.log('The service exists: ', svc.exists);
});
svc.uninstall();
Note that the uninstall process only removes process-specific files. It does not delete your Node.js script.
FAQs
Run Node.js scripts as native services on Windows, Mac OS and Linux.
The npm package desktop-service receives a total of 16 weekly downloads. As such, desktop-service popularity was classified as not popular.
We found that desktop-service demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.