DEV Community

Cover image for How to start node.js app with pm2
Himanshu Gupta
Himanshu Gupta

Posted on

How to start node.js app with pm2

PM2 is a popular process manager that offers all of the features above and then some. It has great documentation and is quick to get started with, which is why I’ve chosen to use it for a number of my applications.

Installing PM2
The PM2 CLI can be installed using npm by running the following in your terminal:

npm install pm2 -g
Running the Application with PM2

To start a file, you can use this command, pm2 start index.js , where index.js is the path to the file that you want to run.
Helpful PM2 Commands

pm2 stop [insert id]— Will stop the process that matches the id (run the list command to get the id)

pm2 start [insert id] — Will start the process that matches the id

pm2 logs [insert id] — Shows logs from the process that matches the id

pm2 delete [insert id] — Will delete the process that matches the id

For more information check Reference Link:

pm2 — npm (npmjs.com)

Top comments (0)