coreybutler / node-windows

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

Error:1067 : The process terminated unexpectedly. #314

Closed aviralgoyal closed 2 years ago

aviralgoyal commented 2 years ago

Issue: NodeJs Application running successfully as service on most systems, but on some systems the service fails to start with the following error:

Windows could not start the service on local computer
Error:1067 : The process terminated unexpectedly.

On checking Windows Logs following:

Starting C:\Program Files\nodejs\node.exe  --harmony --max_old_space_size=4096 C:\Users\Administrator\AppData\Roaming\npm\node_modules\node-windows\lib\wrapper.js --file C:\texma-sync-AAU2TX2\app.js --scriptoptions= --log "TEXMA-SYNC-AAU2TX2 wrapper" --grow 0.25 --wait 1 --maxrestarts 3 --abortonerror n --stopparentfirst false
Service started successfully.
Child process [7484 - C:\Program Files\nodejs\node.exe  --harmony --max_old_space_size=4096 C:\Users\Administrator\AppData\Roaming\npm\node_modules\node-windows\lib\wrapper.js --file C:\texma-sync-AAU2TX2\app.js --scriptoptions= --log "TEXMA-SYNC-AAU2TX2 wrapper" --grow 0.25 --wait 1 --maxrestarts 3 --abortonerror n --stopparentfirst false] finished with -1073741502

nodejs v14 Windows 10

I am unable to debug the issue as the same service is running fine on one system and not on another. Don't know how to debug or reproduce the error.

Is there a way to debug the issue? Or is this a known issue?

echoleyo commented 2 years ago

I can reproduce the same issue, myService can be installed successfully, but can't start, if you start from Service explorer, getting error

Windows could not start the service on local computer
Error:1067 : The process terminated unexpectedly.

and I run myService from daemon folder directly, I am getting error below:

Cannot start service from the command line or debugger. A winwows Service must first be 
installed(using installutil.exe) and then started with the ServerExplorer, Windows Services 
Administrative tool or the NET START command.

the change I recently made on my Windows 10 is the Win10 got IT updated to version 20H2 so my OS is now

Edition: Windows 10 Enterprise
Version: 20H2
OS build: 19042.1645
Node JS: v16.13.1

also the myService was able to restarted before OS upgrade, after OS upgrade I can no longer start myService anymore.

here is myService.err from daemon/

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module '@author.io/args'
Require stack:
- C:\Users\echoleyo\AppData\Roaming\npm\node_modules\node-windows\lib\wrapper.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (C:\Users\echoleyo\AppData\Roaming\npm\node_modules\node-windows\lib\wrapper.js:3:12)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\echoleyo\\AppData\\Roaming\\npm\\node_modules\\node-windows\\lib\\wrapper.js'
  ]
}
echoleyo commented 2 years ago

I found the similar issue from another thread, the difference is that all my services are still there after OS upgrade, and it shows running, but it actually not functional correctly, then I tried to restart my service, it can no longer restart anymore, seems like there are some restriction on install and run the service? https://github.com/coreybutler/node-windows/issues/231#issuecomment-880982025

G4LH4 commented 2 years ago

Same problem here. Any solutions?

mdodge-ecgrow commented 2 years ago

I'm getting the same issue. I had it running and then made some changes to my node server, restarted the service and it no longer runs now. I see the same errors in my err.log file.

mdodge-ecgrow commented 2 years ago

For those coming here stuck, there is a workaround in the other thread about this here: https://github.com/coreybutler/node-windows/issues/308 Basically downgrade to 1.0.0-beta.6

nassau-t commented 2 years ago

Same problem, Error 1067 after 1.0.0-beta7 upgrade. Windows 10. Node 18.3.0. If I uninstall service, it prompts a windows window to install a windows .net framework 2.5 or 3.0 or something like that.

I have downgraded to 1.0.0-beta6 and it works well, as before.

Phierdomenico commented 2 years ago

Thanks @nassau-t! Here the same issue, we downgraded and everything went well...waiting for news about this issue

lavrinenko commented 2 years ago

1.0.0-beta8 - Error 1067 repeated again 1.0.0-beta6 - Works good

UPD: Removed node-windows via npm + removed the node_modules and .package folder in the project. Installed on the new node-windows and everything worked, thanks to the author for the work!

coreybutler commented 2 years ago

Several issues have been brought up. I'll try to address them.

First, version 1.0.0-beta.7 had a dependency that only worked with ESM. This was resolved in 1.0.0-beta.8. The only difference between v1.0.0-beta.6 and v1.0.0-beta.8 is that the vulnerable optimist dependency was replaced with the yargs module.

When processes launch but terminate early, it means node-windows successfully installed the service and started it, but it ended abruptly. 99% of the time, this is due to the script or something happening on the operating system. When upgrading Windows, the most common root causes are permissions. Make sure the user account running the service still has permissions to do what it needs to do, specifically with folder read/write permissions. Another common problem with upgrading Windows are the updates to Defender, which will sometimes block ports that were previously open. In Windows 11, some people enable Protected Folders, which may block the node-windows executable from running, as shown in the screenshot below:

image

When re-installing/upgrading node-windows, those who use a version manager need to remember node-windows needs to be reinstalled for each version.

When upgrading node-windows, you may need to reinstall your services in order to bundle the latest code. The XML manifest that's bundled in the output of each installation provides paths to the node-windows wrapper.js file. That's the file that uses yargs instead of optimist now. Existing services need to point to the appropriate wrapper.js file. Most users will not have to do anything to make this work if node-windows is installed in the same location it was before. However; any running services will need to be restarted to use the new wrapper.js file.

I'm closing this because I do not think most of these issues are node-windows related, except for those related to v1.0.0-beta.7, which is now deprecated in favor of v1.0.0-beta.8. Please open a new issue if you are still having trouble with terminated processes.