PM2 is a process manager for Node.js. It keeps your app running, restarts on crash, starts on system boot, and provides log management. Without PM2, the app stops when the SSH session ends or on an unhandled error.
Installing Node.js and PM2 on AWS EC2 Setting Up the Production Environment
What is PM2 and why use it for Node.js?
The answer
More FAQs in Installing Node.js and PM2 on AWS EC2 Setting Up the Production Environment
Use the NodeSource repository: curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -, then sudo apt install -y nodejs. This installs Node.js 20 LTS and npm.
Run pm2 startup systemd, copy and run the outputted command, then run pm2 save to save the current process list. PM2 will automatically restart your apps when the server reboots.
Node.js 20 LTS (via NodeSource), PM2 (sudo npm install -g pm2), Nginx (sudo apt install nginx), Git (sudo apt install git), and build-essential for npm packages that require compilation.
Still have questions?
Browse all our FAQs or reach out to our support team
Want to upskill yourself?
Your learning library
Small steps. Big possibilities.
Find your next course. Build something great.