简体   繁体   English

无法在 OS 10.15.5 中安装 pm2

[英]Cannot install pm2 in OS 10.15.5

Mac os Catalina 10.15.5 / npm version 6.14.5

When I install pm2, it seems that it is being installed without any problem.当我安装 pm2 时,它似乎正在安装没有任何问题。 But if I run pm2, the terminal only says that command not found.但是如果我运行 pm2,终端只会说找不到该命令。 It's not working at all.它根本不起作用。 It just doesn't start.它只是没有开始。

I searched through StackOverflow and tried the following solutions.我搜索了 StackOverflow 并尝试了以下解决方案。

- npm i -g pm2
- sudo npm install -g pm2
- npm i pm2@latest --no-optional -g --no-shrinkwrap
- sudo npm install pm2 -g --unsafe-perm

All of the above gives me this result.以上所有都给了我这个结果。

/Users/myname/.npm-global/bin/pm2 -> /Users/myname/.npm-global/lib/node_modules/pm2/bin/pm2
/Users/myname/.npm-global/bin/pm2-docker -> /Users/myname/.npm-global/lib/node_modules/pm2/bin/pm2-docker
/Users/myname/.npm-global/bin/pm2-dev -> /Users/myname/.npm-global/lib/node_modules/pm2/bin/pm2-dev
/Users/myname/.npm-global/bin/pm2-runtime -> /Users/myname/.npm-global/lib/node_modules/pm2/bin/pm2-runtime
+ pm2@4.4.0
updated 1 package in 4.768s

After this,在这之后,

If I type pm2 : I get pm2-bash: pm2: command not found如果我输入pm2 :我得到pm2-bash: pm2: command not found
If I type whereis pm2 : it just doesn't do anything at all.如果我输入whereis pm2 :它根本不做任何事情。
If I type pm2 start index.js in VScode terminal: zsh: command not found: pm2如果我在 VScode 终端中键入 pm2 pm2 start index.jszsh: command not found: pm2

And there are the files inside of the path( /Users/myname/.npm-global/bin/ ).并且路径中有文件( /Users/myname/.npm-global/bin/ )。 I don't know what the problem is.我不知道问题是什么。 Any help or advice will be appreciated.任何帮助或建议将不胜感激。

those who are having the same problem, hope it helps.有同样问题的朋友,希望对你有帮助。 After repeating countless uninstall & install of node/npm/pm2 whatsoever and toying around the permissions, I found answer by myself.在重复无数次卸载和安装 node/npm/pm2 并玩弄权限之后,我自己找到了答案。

  1. Changed default command shell from zsh to bash.将默认命令 shell 从 zsh 更改为 bash。 (in VScode as well)*** (在 VScode 中也是如此)***
  2. Deleted all the node & npm and installed nvm, and re-installed node via nvm.(npm is automatically installed together).删除所有node & npm 并安装nvm,并通过nvm重新安装node。(npm自动安装在一起)。
  3. Installed pm2 with npm.用 npm 安装 pm2。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM