DEV Community

Cover image for Install PM2
Ruben Alvarado
Ruben Alvarado

Posted on

Install PM2

Originally posted on Web Warrior Toolbox

On a server where you’ve already installed npm or pnpm, you can add PM2 to manage your backend application.

If you’re not sure about your fnm/pnpm setup, check this tutorial.

Why PM2?

PM2 provides features you don’t get by simply running npm run start or pnpm run dev:

  • Simple startpm2 start dist/main.js
  • Health checkpm2 ls shows running apps
  • Auto‑restart on reboot → configure with pm2 startup
  • Consistency → same commands everywhere, instead of arbitrary start/dev/prod scripts chosen by different developers

In short: PM2 gives you peace of mind and a unified workflow.

To install pm2 you have 2 paths:

Method Command Pros Cons
npm global `npm install -g pm2` Works out of the box, PATH already set Slightly heavier installs
pnpm global `pnpm add -g pm2` Disk space efficient Needs PATH fix (`~/.local/share/pnpm`)

In this case I recommend using npm so you won't need to fix the path.

Install with npm

npm install -g pm2
pm2 --version
Enter fullscreen mode Exit fullscreen mode

Use this for your projects and keep updating your knowledge 🙌, Dev-san.

Top comments (0)