Thursday, 25 May 2017

node-mac does not run the script

I am using node-mac to run nodejs script as a service on macOS. I am using following script. After running below script in terminal using node index.js it does output STARTED but when I check that in my system's Activity Monitor I do not see this service in the list either. According to official example https://github.com/coreybutler/node-mac it should work.

index.js file

var Service = require('node-mac').Service;

// Create a new service object
var svc = new Service({
    name:'Hello World',
    description: 'The nodejs.org example web server.',
    script: './HelloWorld.js'
});

svc.on('start', () => {
    console.log('STARTED');
});

svc.start();

HelloWorld.js file

console.log('Hello World');

How can I make this work?



via doforuma

No comments:

Post a Comment