pm2-installer icon indicating copy to clipboard operation
pm2-installer copied to clipboard

PM2 service cannot be restarted after Node.js upgrade

Open simone80an opened this issue 2 years ago • 2 comments

Description I have upgraded Node.js for Windows to latest current stable version (16.15.0), updated PM2 and the PM2 Windows Service cannot be restarted.

Steps to Reproduce

  1. I stopped PM2 Windows service that was running
  2. Upgraded Node.js to latest stable version using nvm for Windows, i followed this guide https://www.geeksforgeeks.org/how-to-update-node-js-and-npm-to-next-version/
  3. Updated npm npm install -g npm
  4. Updated pm2 npm install pm2 -g and then pm2 update
  5. Restarting the PM2 Windows service says that the service cannot be started, the Windows Event Viewer don't give further helpful details

Additional info After i did the steps 1 to 4 i also did the removal procedure and deconfigure of pm2-installer and did it again the setup and configure, the service will be installed but then don't start, it says "State is now: Stopped" forever in a loop

Environment Running on: 29/4/2022, pm2-installer 3.3.2 with node v16.15.0 and npm 8.8.0 on win32-10.0.17763. Machine is Windows Server 2019 Standard.

simone80an avatar Apr 29 '22 09:04 simone80an

Same here. I can't start a windows service. I get this message: The PM2 service could not be started on the Local computer. Error 1067: The process was terminated unexpectedly.

And have this in log fie:

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

Error: Cannot find module 'C:\Users\Felix\AppData\Roaming\npm\node_modules\node-windows\lib\wrapper.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:939:15)
    at Module._load (node:internal/modules/cjs/loader:780:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v18.2.0

This happens to on Node.js versions 16.15.0 and 15.14.0

nerdError avatar May 31 '22 22:05 nerdError

I have tried again using the latest PM2-installer version (3.4.0). I have updated Node.js to latest stable version, currently v16.15.1 (using NVM for Windows downloaded from https://github.com/coreybutler/nvm-windows), npm was also updated to v8.12.1. I have updated pm2 to v5.2.0.

Still im not able to start the PM2 service. If i try from Windows services it says that the PM2 service could not be started on the Local computer. There aren't any logs in the Event Viewer, btw from pm2.wrapper.log file that i found in C:\ProgramData\pm2\service\daemon i can see:

2022-06-03 11:53:59 - Failed to log event in Windows Event Log: Starting C:\Program Files\nodejs\node.exe --harmony C:\ProgramData\npm\npm\node_modules\node-windows\lib\wrapper.js --file C:\ProgramData\pm2\service\index.js --scriptoptions= --log "PM2 wrapper" --grow 0.25 --wait 1 --maxrestarts 3 --abortonerror n --stopparentfirst true; Reason: Message:The source was not found, but some or all event logs could not be searched. To create the source, you need permission to read all event logs to make sure that the new source name is unique. Inaccessible logs: Security, State. Stacktrace: at System.Diagnostics.EventLog.FindSourceRegistration(String source, String machineName, Boolean readOnly, Boolean wantToCreate) at System.Diagnostics.EventLog.SourceExists(String source, String machineName, Boolean wantToCreate) at System.Diagnostics.EventLogInternal.VerifyAndCreateSource(String sourceName, String currentMachineName) at System.Diagnostics.EventLogInternal.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData) at System.Diagnostics.EventLog.WriteEntry(String message) at winsw.WrapperService.LogEvent(String message)

Before doing npm run setup command naturally i executed the commands npm run configure and npm run configure-policy successfully.

I then tried pm2-service-install but using the fork from @innomizetech which is from 2019 and has no bugs, it works perfectly following from instructions https://stackoverflow.com/questions/42758985/windows-auto-start-pm2-and-node-apps and it works without any issues.

simone80an avatar Jun 03 '22 10:06 simone80an