Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PM2 command not found

Tags:

linux

node.js

I installed node.js and npm to my centOS 7 server. But i have problems with pm2. Actually real problem is i don't have experiences in linux and i don't know how to change path. Here is folder structure.

* bin * code * error_docs * httpdocs * lib64 * logs * tmp * var * chat(my node.js folder)     * node_modules         * pm2         * sockjs     * server.js * dev * etc * lib * local * sbin * usr 

I entered folder by typing cd chat and installed pm2 with npm install pm2.

After that I tried use pm2 for my server.js by typing pm2 server.js server returns "pm2 command not found". I can use node.js without any problem but pm2 not working.

How can i solve this?

like image 224
kenarsuleyman Avatar asked Jul 04 '16 13:07

kenarsuleyman


People also ask

What is pm2 and commands?

Pm2 is a process management module for Node. js applications. It is used to start and monitor Node. js application so if the application goes down ( for example if the node index. js process dies) the process manager will restart the app immediately making it available once again.


1 Answers

Install PM2 globally:

run as root:

npm i -g pm2 

or if user is sudo-er

sudo npm i -g pm2 

and then go back to user (or stay in root if it was created by root user) and run it:

pm2 start server.js 
like image 119
num8er Avatar answered Sep 19 '22 12:09

num8er