PM2 is an advanced process manager for running Node.js applications. That provides an easier option to automate a Node.js application. We can quickly do the start, stop, or other operations on applications. Many of the Node.js applications use “npm start” to run. In this quick how-to guide, we will help you to run “npm start” using pm2.
Assuming that you already have Node.js installed on your system. If you haven’t already, visit our tutorial to install Node.js using nvm.
- Installing PM2: Make sure you have installed PM2 globally on your machine with this command:
npm install pm2 --location=global
After installing pm2, run “pm2 startup” once to configure auto-start pm2 during system reboot.
- Start npm: PM2 also supports to run npm start:
pm2 start npm -- start
--nameoption to assign a name to the PM2 process.
pm2 start npm --name "my_app" -- start
Hopefully, this article helped you to run the NPM application using the pm2 process manager.