pm2 Error: Cannot find module 'xxx'

created at 07-06-2021 views: 2

description

error message:

Error: Cannot find module '/usr/local/Cellar/node/14.5.0/lib/node_modules/pm2/lib/ProcessContainerFork.js'

The error occurred after I upgraded the version of node 14.5.0->14.9.0.

pm2 start app.js

Found that the startup is normal:

startup is normal

then check:

pm2 ls

Found that the status changed to errored and reported an error, / confused

 status changed to errored

check the log again:

pm2 logs

Error message found

logs

It's weird why I still found the node package file before the upgrade. At first I thought it was a problem with my node path configuration. Where did I not replace and adjust the old version, I checked it and found that there was no problem. / Scratching my head, I wondered if the installation of pm2 was wrong. , I started uninstall, install repeatedly and found that it still reported an error, / scratching my head vigorously
Started to search for errors, and found a few articles that were not reliable, and finally found a similar one, there is this reply.

solution

The reason is you pm2 env is modified, please try run command below to delete your pm2 env dir from your home dir.

rm -rf ~/.pm2

The restart is OK, ~ happy

 restart is OK

status

reference

Please log in to leave a comment.