Proper way to update PM2 after updating Node.js

In console :

  1. pm2 save --First make sure that you saved correctly all your processes
  2. npm install pm2 -g --Then install the latest PM2 version from NPM
  3. pm2 update --And finally update the in-memory PM2 process

It's seem there no way without re-installing PM2 after a Node update :-(

$ nvm install 6.11.3 --reinstall-packages-from=6.11.2 && nvm alias default 6.11.3
$ nvm uninstall 6.11.2
$ pm2 update # Update in memory pm2
$ pm2 startup
$ nano /etc/init.d/pm2-init.sh  # Wrong path :-(

But re-installing pm2 is not enought, some things are still broken even if it seem to work, logs are no more in real time for example My hot fix :

$ rm -rf /root/.pm2
$ pm2 reload pm2.json --env production
$ pm2 startup ubuntu

Do not forget to rebuild packages after updating the version of node.js:

cd /to/root/of/your/project
npm rebuild
npm i -g pm2 && pm2 update

# here 0 and dist/main.js change for your project
pm2 delete 0 && pm2 start dist/main.js

Tags:

Node.Js

Pm2