coreybutler / node-windows

Windows support for Node.JS scripts (daemons, eventlog, UAC, etc).
Other
2.83k stars 356 forks source link

Cannot start service, bug in node-windows or nodegit? #202

Closed mfechner closed 6 years ago

mfechner commented 6 years ago

Dear all,

to be sure were to address this bug I would like to ask if you can quickly look over the code if it is correct. I stripped it down to a minimum example to show this bug. I described everything in the README.md to reproduce it, you can find everything here: https://gitlab.fechner.net/mfechner/nodegit_node-windows

Could you please have a quick look into installWindowsService.js if this code is correct? https://gitlab.fechner.net/mfechner/nodegit_node-windows/blob/master/installWindowsService.js

I think it is a bug with nodegit, but I would like to be sure, before I create a bug report there. The error message I see in daemon\nodegitwindowssservice.err.log:

C:\Applications\nodegit_node-windows\node_modules\nodegit\dist\nodegit.js:825
      throw unhandledException;
      ^

TypeError: Cannot read property '1' of null
    at module.exports (C:\Applications\nodegit_node-windows\node_modules\promisify-node\utils\args.js:9:63)
    at C:\Applications\nodegit_node-windows\node_modules\promisify-node\index.js:79:29
    at Array.filter (<anonymous>)
    at processExports (C:\Applications\nodegit_node-windows\node_modules\promisify-node\index.js:60:6)
    at module.exports (C:\Applications\nodegit_node-windows\node_modules\promisify-node\index.js:112:10)
    at Object.<anonymous> (C:\Applications\nodegit_node-windows\node_modules\nodegit\dist\repository.js:6:11)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
C:\Applications\nodegit_node-windows\node_modules\nodegit\dist\nodegit.js:825
      throw unhandledException;
      ^

TypeError: Cannot read property '1' of null
    at module.exports (C:\Applications\nodegit_node-windows\node_modules\promisify-node\utils\args.js:9:63)
    at C:\Applications\nodegit_node-windows\node_modules\promisify-node\index.js:79:29
    at Array.filter (<anonymous>)
    at processExports (C:\Applications\nodegit_node-windows\node_modules\promisify-node\index.js:60:6)
    at module.exports (C:\Applications\nodegit_node-windows\node_modules\promisify-node\index.js:112:10)
    at Object.<anonymous> (C:\Applications\nodegit_node-windows\node_modules\nodegit\dist\repository.js:6:11)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
C:\Applications\nodegit_node-windows\node_modules\nodegit\dist\nodegit.js:825
      throw unhandledException;
      ^

TypeError: Cannot read property '1' of null
    at module.exports (C:\Applications\nodegit_node-windows\node_modules\promisify-node\utils\args.js:9:63)
    at C:\Applications\nodegit_node-windows\node_modules\promisify-node\index.js:79:29
    at Array.filter (<anonymous>)
    at processExports (C:\Applications\nodegit_node-windows\node_modules\promisify-node\index.js:60:6)
    at module.exports (C:\Applications\nodegit_node-windows\node_modules\promisify-node\index.js:112:10)
    at Object.<anonymous> (C:\Applications\nodegit_node-windows\node_modules\nodegit\dist\repository.js:6:11)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
C:\Applications\nodegit_node-windows\node_modules\node-windows\lib\wrapper.js:177
    child.send('shutdown');
          ^

TypeError: Cannot read property 'send' of null
    at process.killkid (C:\Applications\nodegit_node-windows\node_modules\node-windows\lib\wrapper.js:177:11)
    at process.emit (events.js:160:13)
    at process.exit (internal/process.js:147:15)
    at monitor (C:\Applications\nodegit_node-windows\node_modules\node-windows\lib\wrapper.js:99:17)
    at ChildProcess.<anonymous> (C:\Applications\nodegit_node-windows\node_modules\node-windows\lib\wrapper.js:170:5)
    at ChildProcess.emit (events.js:160:13)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)

Thanks a lot.

jdziat commented 6 years ago

@mfechner This issue is actually with node-git not supporting the --harmony flag you need to disable that and change your working directory to where the app.js file lives. This solved the issue on my system and i was able to get it to load properly.

The below snippet worked for me and should work for you as well. I'm going to mark this as closed.

var svc = new Service({
    name: 'nodegitWindowsService',
    description: 'Show nodegit does not work with node-windows.',
    script: path.join(__dirname, 'app.js'),
    workingdirectory:path.join(__dirname, 'app.js'),
    nodeOptions:[]
});
mfechner commented 6 years ago

@jdziat thanks a lot this fixed it.