Cannot run node module as service

391 Views Asked by At

I'm trying to run the node module npm-lazy as a service in my localzone. If I run the start command on the commandline It works well. I'm running it with:

npm_lazy --config /etc/npm-lazy-config.js

But if want to run the module as a service it constantly gets this errormessage:

[ Apr  9 01:13:31 Executing start method ("/opt/local/bin/npm_lazy --config /etc/npm-lazy-config.js"). ]

path.js:336
    var isAbsolute = path.charAt(0) === '/',
                          ^
TypeError: Cannot call method 'charAt' of undefined
    at Object.exports.normalize (path.js:336:27)
    at Object.<anonymous> (/opt/local/lib/node_modules/npm_lazy/config.js:2:21)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/opt/local/lib/node_modules/npm_lazy/bin/npm_lazy:37:14)
    at Module._compile (module.js:456:26)
[ Apr  9 01:13:32 Stopping because service exited with an error. ]
[ Apr  9 01:13:32 Executing start method ("/opt/local/bin/npm_lazy --config /etc/npm-lazy-config.js"). ]

I created the service with manifold, I added all the directories to the envvar section in my created service.xml I got from

echo $PATH

but It seems the "path" dependency for nodejs can't be found. Please help.

1

There are 1 best solutions below

0
On

It looks like npm_lazy is assuming that the HOME environment variable will be set, but it's not set in the SMF. You can set that by adding it to the envvar section of the XML manifest.