pm2 icon indicating copy to clipboard operation
pm2 copied to clipboard

cannot find module pm2/lib/ProcessContainerFork.js

Open evalenzuela opened this issue 10 years ago • 20 comments

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

evalenzuela avatar Feb 12 '16 00:02 evalenzuela

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

Unitech avatar Feb 15 '16 12:02 Unitech

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.

maxinmos avatar Aug 10 '16 17:08 maxinmos

In my case pm2 update solved it

wojtek-krysiak avatar May 09 '17 18:05 wojtek-krysiak

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

redhat-raptor avatar Oct 07 '17 07:10 redhat-raptor

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)

oceansync avatar Dec 25 '18 10:12 oceansync

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...

khelkun avatar Jul 08 '20 16:07 khelkun

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.

It is 2021! and this answer worked for me! Thanks!

DaggieBlanqx avatar Feb 02 '21 14:02 DaggieBlanqx

pm2 start npm --name projectName -- run develop this worked for me

tewedaj avatar Jul 26 '21 16:07 tewedaj

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.

it's 2021-08. answer still work for me. cool

yangxiaolin avatar Aug 22 '21 05:08 yangxiaolin

I had 2 versions of node 16.x and 17.x and i installed pm2 globally two times by interchanging the node versions but it still didn't work for me. Then i check the status of pm2 by deleting all the processes. And used the command "pm2 startup" to make it run at server startup. They will give a command just copy and paste the command and hit enter. After that run pm2 instance and you will be good to go.

tamurtaj85 avatar Dec 06 '21 08:12 tamurtaj85

Thanks @maxinmos ❤️❤️ rm -rf .pm2 worked for me.

crazyoptimist avatar Oct 13 '22 00:10 crazyoptimist

cd && rm -rf .pm2 works for me as well. I used to have PM2 installed globally, switching to a local install now for testing, and removing the .pm2 folder is the trick, if someone can explain why, feel free to do so!

notflip avatar Feb 22 '23 18:02 notflip

It is 2023-12-15. The answer rm -rf .pm2 still work for me (for pm2 5.3.0). WHY??

qiulang avatar Dec 15 '23 05:12 qiulang

In my case pm2 update solved it

It Actually solved the issue

sriharishjayaraman avatar Mar 14 '24 11:03 sriharishjayaraman

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.

its 2024 -03 and solved the issue

Thank you btw.

MonishKrishna2009 avatar Mar 30 '24 15:03 MonishKrishna2009

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.

it's 2021-08. answer still work for me. cool

2024-06 still works.

I think this is an issue with pm2 when it has some old instances that can't even be cleared with pm2 kill.
However rm -rf ~/.pm2 fixes the issue and you can start over.

Gkiokan avatar Jun 08 '24 00:06 Gkiokan

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.

it's 2024-11. answer still work for me. cool

terwer avatar Nov 16 '24 08:11 terwer

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.

Yep this still works

banphlet avatar Dec 24 '24 11:12 banphlet

It's 16th January 2026. rm -rf ~/.pm2 still works.

chengluyu avatar Jan 15 '26 18:01 chengluyu

It's 28th Jan 2026. rm -rf ~/.pm2 still works. It's a bug. Nobody fix it?

jim-king-2000 avatar Jan 28 '26 10:01 jim-king-2000