找不到PM2命令 [英] PM2 command not found
问题描述
我在我的centOS 7服务器上安装了node.js和npm.但是我对pm2有问题. 实际上,真正的问题是我没有Linux经验,也不知道如何更改路径. 这是文件夹结构.
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
我通过输入cd chat
进入文件夹,并用npm install pm2
安装了pm2.
I entered folder by typing cd chat
and installed pm2 with npm install pm2
.
之后,我尝试通过键入pm2 server.js
将pm2用于我的server.js,服务器返回找不到pm2命令".我可以毫无问题地使用node.js,但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.
我该如何解决?
推荐答案
全局安装PM2:
以root身份运行:
npm i -g pm2
或者如果用户是sudo-er
or if user is sudo-er
sudo npm i -g pm2
,然后返回到用户(如果它是由root用户创建的,则留在root用户中)并运行它:
and then go back to user (or stay in root if it was created by root user) and run it:
pm2 start server.js
这篇关于找不到PM2命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!