centOS 8 pm2: command not found

  • Post author:
  • Post category:其他


本人尝试在阿里云的服务器通过pm2部署项目,安装pm2:

npm install pm2@latest -g


但:

# pm2 -v
bash: pm2: command not found

在网上查阅大部分资料后,提炼出来的有效信息:

  • 问题是没有正确的软连接;
  • 但centOS8的应该是软连接到

    /usr/bin/pm2

    而不是centOS7的

    /usr/local/bin/



    查阅至

    );
  • 通过

    whereis pm2

    查看位置;

查看安装时软连接的位置,如下:

npm WARN deprecated uuid@3.4.0: Please upgrade  to version 7 or higher.  Older versions may use Math.random() in certain circumstances, which is known to be problematic.  See https://v8.dev/blog/math-random for details.
/usr/local/bin/pm2 -> /usr/local/lib/node_modules/pm2/bin/pm2
/usr/local/bin/pm2-dev -> /usr/local/lib/node_modules/pm2/bin/pm2-dev
/usr/local/bin/pm2-docker -> /usr/local/lib/node_modules/pm2/bin/pm2-docker
/usr/local/bin/pm2-runtime -> /usr/local/lib/node_modules/pm2/bin/pm2-runtime
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/pm2/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ pm2@5.2.0
updated 1 package in 19.15s

设置软连接:

ln -s /usr/local/lib/node_modules/pm2/bin/pm2 /usr/bin/

如果出现错误:

ln: failed to create symbolic link '/usr/bin/pm2': File exists

将其删除:

mv /usr/bin/pm2 /tmp/
mv: overwrite '/tmp/pm2'? y

查看:

which pm2
# /bin/pm2

运行:

pm2 -v
# 5.2.0



版权声明:本文为m0_51221102原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。