bash 找不到 NPM 命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16530898/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NPM Command Not Found
提问by Connor Black
I just updated node (through the nodejs.org package installer) and now npmwon't work.
我刚刚更新了节点(通过 nodejs.org 包安装程序),现在npm无法工作。
npm: command not found
npm: command not found
Any idea what's going on?
知道发生了什么吗?
采纳答案by JimBtek
I was hung up on this too. I installed node via nvm and could not run npm or node. I had to run nvm use 0.10.10
我也被这件事挂了。我通过 nvm 安装了 node,但无法运行 npm 或 node。我不得不跑nvm use 0.10.10
then which nodeand which npmworked again.
然后which node又which npm工作了。
if you have installed npmvia nvmyou might want to add nvm use <version>to your .bashrcfile so that you'll have npmalways available on any shell you open. You just need to remember to update it whenever you update npm, or use stable.
如果您已经npm通过安装,nvm您可能希望添加nvm use <version>到您的.bashrc文件中,以便您npm在打开的任何 shell 上始终可用。你只需要记住在更新 npm 时更新它,或者使用stable.
回答by Rajesh
It could be a permission issue as well. If so you need to run this: sudo chown -R $USER /usr/local
这也可能是一个许可问题。如果是这样,你需要运行这个: sudo chown -R $USER /usr/local
This worked for me
这对我有用

