pm2
Production process manager for Node.js — cluster mode, zero-downtime reloads, log management, and startup scripts.
pm2
Node.jsProduction process manager for Node.js — cluster mode, zero-downtime reloads, log management, and startup scripts.
Fit
Install size includes transitive dependencies. Bundle size is gzipped browser payload.
Freshness
The Problem
Running a Node.js app in production means handling crashes (auto-restart), multi-core utilization (cluster mode), log rotation, and starting the app automatically on server reboot — none of which the node command provides.
What It Does
PM2 runs your app as a managed process, restarts it on crash, spreads load across CPU cores with cluster mode, streams logs with rotation, and generates systemd/init scripts for boot persistence. The pm2 monit dashboard shows CPU and memory usage in real time.
Installation
npm install -g pm2Usage Example
# Start in cluster mode across all CPU cores
pm2 start dist/server.js --name "my-api" -i max
# Zero-downtime reload after deployment
pm2 reload my-api
# View logs
pm2 logs my-api
# Save process list and generate startup script
pm2 save
pm2 startup// ecosystem.config.js
module.exports = {
apps: [{ name: 'api', script: 'dist/server.js', instances: 'max', exec_mode: 'cluster' }]
};Related packages
Role and attribute based access control (RBAC + ABAC) for Node.js with a fluent, readable API.
bcryptjsNode.jsPure JavaScript bcrypt password hashing — no native dependencies, same API as bcrypt, works anywhere Node.js runs.
bullmqNode.jsPremium message queue and job scheduler for Node.js backed by Redis — reliable background job processing with retries, priorities, and rate limiting.
casbinNode.jsA powerful authorization library that supports RBAC, ABAC, ACL and more via configurable policy models.
dotenvNode.jsLoad environment variables from a `.env` file into `process.env` — the standard way to manage configuration in Node.js apps.