0

I'm trying to launch node.js application with pm2. I've installed pm2: sudo npm install pm2 -g

Now, if I launch pm2 as non-root user it works fine. But if I try to run: sudo pm2 logs I have an error: pm2: command not found

pm2 logs works fine

If I use a sh-script to launch: sudo sh run.sh there is another error in logs:

events.js:72         
throw er; // Unhandled 'error' event               
^ Error: connect EACCES

How can I launch pm2 as super-user, to make sure that other users can launch and restart applications with sudo pm2 monit or sudo pm2 restart appname etc..?

4

1 回答 1

2

最显然pm2没有在PATHfor root 中列出。

检查PATH非root用户和root用户是否相同

$ echo 'echo $PATH' | sh
$ echo 'echo $PATH' | sudo sh

pm2如果不为 root添加缺少的路径

于 2014-12-17T15:33:16.953 回答