cannot find module pm2/lib/ProcessContainerFork.js
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
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...
I have the same issue. After some research, I followed a solution what I found on this stackoverflow.
Using
rm -rf ~/.pm2and it worked.
It is 2021! and this answer worked for me! Thanks!
pm2 start npm --name projectName -- run develop
this worked for me
I have the same issue. After some research, I followed a solution what I found on this stackoverflow.
Using
rm -rf ~/.pm2and it worked.
it's 2021-08. answer still work for me. cool
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.
Thanks @maxinmos ❤️❤️
rm -rf .pm2 worked for me.
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!
It is 2023-12-15. The answer rm -rf .pm2 still work for me (for pm2 5.3.0). WHY??
In my case
pm2 updatesolved it
It Actually solved the issue
I have the same issue. After some research, I followed a solution what I found on this stackoverflow.
Using
rm -rf ~/.pm2and it worked.
its 2024 -03 and solved the issue
Thank you btw.
I have the same issue. After some research, I followed a solution what I found on this stackoverflow. Using
rm -rf ~/.pm2and 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.
I have the same issue. After some research, I followed a solution what I found on this stackoverflow.
Using
rm -rf ~/.pm2and it worked.
it's 2024-11. answer still work for me. cool
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
It's 16th January 2026. rm -rf ~/.pm2 still works.
It's 28th Jan 2026. rm -rf ~/.pm2 still works. It's a bug. Nobody fix it?