Search code examples
node.jsdaemonmonitorpm2

How to start the node.js application using pm2


I have installed pm2 module using the following command:
npm install pm2@latest

Then I tried to start my test application using pm2 as follows:
$ pm2 start test.js

It throws the following error:
'pm2' is not recognized as an internal or external command

Do i need to set environment variable for pm2?


Solution

  • You need to install PM2 globally via npm install --global pm2@latest and if you want to use the local version, try ./node_modules/.bin/pm2 start test.js.