Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
desktop-service
Advanced tools
Run Node.js scripts as native services on Windows, Mac OS and Linux.
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.