Pm2: cannot find module pm2/lib/ProcessContainerFork.js

Created on 12 Feb 2016  路  6Comments  路  Source: Unitech/pm2

Good evening,

I am using webfaction, and just found PM2 module. But I am getting probably a beginner issue.

I have 2 apps running on webfaction. I run npm install pm2 -g while being on app2 folder. If I run pm2 start --name="app2" --watch, all goes well. But then If I go to app1. and run pm2 start --name="app1" --watch. It appears an error: " cannot find module pm2/lib/ProcessContainerFork.js".

What I have noticed is that that file exists on app2 folder structure but no on app1. I guess I need to define a home dir or something?

Thanks in advance for your help

Most helpful comment

I have the same issue. After some research, I followed a solution what I found on this stackoverflow.

Using rm -rf ~/.pm2 and it worked.

All 6 comments

Normally if you install PM2 with the -g option, the module should be global.

Could you install on the root folder instead? It may helps

Also have a look at the cwd option: http://pm2.keymetrics.io/docs/usage/application-declaration/#options

I have the same issue. After some research, I followed a solution what I found on this stackoverflow.

Using rm -rf ~/.pm2 and it worked.

In my case pm2 update solved it

I just had to mkdir -p ~/.pm2/node_modules/

Hello I have the same error and I ran all the above commands but they where no use.
Here is my full error. I am doing this on a nodejs app.

1|app      | Error: Cannot find module '/root/.nvm/versions/node/v11.5.0/lib/node_modules/pm2/lib/ProcessContainerFork.js'
1|app      |     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
1|app      |     at Function.Module._load (internal/modules/cjs/loader.js:529:25)
1|app      |     at Function.Module.runMain (internal/modules/cjs/loader.js:774:12)
1|app      |     at executeUserCode (internal/bootstrap/node.js:342:17)
1|app      |     at startExecution (internal/bootstrap/node.js:276:5)
1|app      |     at startup (internal/bootstrap/node.js:227:5)
1|app      |     at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)

I have the same issue on Windows 10 with a pm2 global isntallation through npm. If I run pm2 start from the root folder of my nodejs expressjs application where lives the ecosystem.config.json:

0|ftl-node | Error: Cannot find module 'G:\my-expressjs-node-app\node_modules\pm2\lib\ProcessContainerFork.js'
0|ftl-node |     at Function.Module._resolveFilename (internal/modules/cjs/loader.js:952:15)
0|ftl-node |     at Function.Module._load (internal/modules/cjs/loader.js:835:27)
0|ftl-node |     at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
0|ftl-node |     at internal/main/run_main_module.js:17:47 {
0|ftl-node |   code: 'MODULE_NOT_FOUND',
0|ftl-node |   requireStack: []
0|ftl-node | }

If pm2 is installed as a local package of my nodejs application, then the issue does not occur...

Was this page helpful?
0 / 5 - 0 ratings