Pm2: After Reboot, `pm2 list` throws `Cannot find module`, then all apps are lost.

Created on 10 Jan 2017  路  2Comments  路  Source: Unitech/pm2

After rebooting

Expected behaviour

After a PC reboot, pm2 list shows a list of previously configured apps

Actual behaviour

After a PC reboot, pm2 list takes a second, then throws an error about not finding a module that is required by one of its apps. Once that error happens, pm2 list becomes empty (all configs are lost).

It's important to note: komada#indev isn't a pm2 app, I didn't add it as such. I'm not in that folder at all. However, the app that was available before reboot was called komada-client and had the komada#indev package as a dependency.

The error:

[PM2] Spawning PM2 daemon with pm2_home=C:\Users\eslac\.pm2
[PM2] PM2 Successfully daemonized
[PM2][Module] Starting module komada#indev
module.js:474
    throw err;
    ^

Error: Cannot find module 'C:\Users\eslac\.pm2\node_modules\komada#indev\package.json'
    at Function.Module._resolveFilename (module.js:472:15)
    at Function.Module._load (module.js:420:25)
    at Module.require (module.js:500:17)
    at require (internal/module.js:20:19)
    at startModule (C:\Users\eslac\AppData\Roaming\npm\node_modules\pm2\lib\API\Modules\Modularizer.js:32:22)
    at C:\Users\eslac\AppData\Roaming\npm\node_modules\pm2\lib\API\Modules\Modularizer.js:272:5
    at C:\Users\eslac\AppData\Roaming\npm\node_modules\pm2\node_modules\async\lib\async.js:181:20
    at replenish (C:\Users\eslac\AppData\Roaming\npm\node_modules\pm2\node_modules\async\lib\async.js:319:21)
    at C:\Users\eslac\AppData\Roaming\npm\node_modules\pm2\node_modules\async\lib\async.js:330:15
    at Object.async.forEachLimit.async.eachLimit (C:\Users\eslac\AppData\Roaming\npm\node_modules\pm2\node_modules\async\lib\async.js:220:35)

Steps to reproduce

Add an app to pm2 (in my case, pm2 start app.js --name "komada" --node-args '--harmony'

  • Run the app, restart, etc, as usual.
  • Restart the computer
  • Run pm2 list from any folder in the command prompt.

Software versions used

OS         : Windows 10 64-bit
node.js    : 7.0.0
PM2        : 2.0.16 (installed globally)

PM2 Log output

2016-12-31 01:41:18: Starting execution sequence in -fork mode- for app name:komada id:0
2016-12-31 01:41:18: App name:komada id:0 online
2016-12-31 01:41:56: App [komada] with id [0] and pid [15632], exited with code [0] via signal [SIGINT]
2016-12-31 01:41:56: Starting execution sequence in -fork mode- for app name:komada id:0
2016-12-31 01:41:56: App name:komada id:0 online
2016-12-31 01:42:56: App [komada] with id [0] and pid [11516], exited with code [0] via signal [SIGINT]
2016-12-31 01:42:56: Starting execution sequence in -fork mode- for app name:komada id:0
2016-12-31 01:42:56: App name:komada id:0 online
2017-01-01 15:37:05: Stopping app:komada id:0
2017-01-01 15:37:05: App [komada] with id [0] and pid [0], exited with code [1] via signal [SIGINT]
2017-01-01 15:37:10: Starting execution sequence in -fork mode- for app name:komada id:0
2017-01-01 15:37:10: App name:komada id:0 online
2017-01-02 01:21:09: Stopping app:komada id:0
2017-01-02 01:21:09: App [komada] with id [0] and pid [0], exited with code [1] via signal [SIGINT]
2017-01-09 22:26:45: ===============================================================================
2017-01-09 22:26:45: --- New PM2 Daemon started ----------------------------------------------------
2017-01-09 22:26:46: Time                 : Mon Jan 09 2017 22:26:45 GMT-0500 (Eastern Standard Time)
2017-01-09 22:26:46: PM2 version          : 2.0.16
2017-01-09 22:26:46: Node.js version      : 7.0.0
2017-01-09 22:26:46: Current arch         : x64
2017-01-09 22:26:46: PM2 home             : C:\Users\eslac\.pm2
2017-01-09 22:26:46: PM2 PID file         : C:\Users\eslac\.pm2\pm2.pid
2017-01-09 22:26:46: RPC socket file      : \\.\pipe\rpc.sock
2017-01-09 22:26:46: BUS socket file      : \\.\pipe\pub.sock
2017-01-09 22:26:46: Application log path : C:\Users\eslac\.pm2\logs
2017-01-09 22:26:46: Process dump file    : C:\Users\eslac\.pm2\dump.pm2
2017-01-09 22:26:46: Concurrent actions   : 4
2017-01-09 22:26:46: SIGTERM timeout      : 1600
2017-01-09 22:26:46: ===============================================================================

Most helpful comment

I had node_modules in my ~/.pm2/ folder for some reason. removed now and seems to be fixed. How they got there I am not sure. Thanks for setting me straight!

All 2 comments

From the error you reported, its looks like you tried to install a normal process as a module, remove the ~/.pm2/dump.pm2 file and remove all modules you have installed and you should be able to start your application without this error.

I had node_modules in my ~/.pm2/ folder for some reason. removed now and seems to be fixed. How they got there I am not sure. Thanks for setting me straight!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

ghost picture ghost  路  3Comments

xzycn picture xzycn  路  3Comments

webchaz picture webchaz  路  3Comments

shaunwarman picture shaunwarman  路  3Comments

liujb picture liujb  路  3Comments