安装节点后找不到 NPM 命令 [英] NPM Command Not Found After Installing Node

查看:105
本文介绍了安装节点后找不到 NPM 命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我很难让 npm 命令正常工作,不幸的是,我对 unix 的了解不足以自己解决这个问题.我所做的只是brew install node,我收到以下错误:

I am having a very hard time getting the npm command to work, and unfortunately my knowledge of unix isn't good enough to solve this on my own. All I've done is brew install node, and I get the following errors:

当我输入 npm 我得到 zsh: command not found: npm

深入研究这个问题,我发现了这个堆栈溢出答案:

Looking into this issue more I found this stack overflow answer:

在 zsh 中安装 npm 后找不到命令

按照它的建议,我尝试将 export PATH=/usr/local/share/npm/bin:$PATH 添加到我的 .zshrc 文件中.输入 npm

Following its advice I tried adding export PATH=/usr/local/share/npm/bin:$PATH to my .zshrc file. Still get the same error when typing npm

我可以确认它在路径 echo $PATH 产生 /Users/nicholashaley/.rbenv/shims:/Users/nicholashaley/.rbenv/bin:/Applications/Postgres.app/Contents/Versions/9.3/bin:/usr/local/heroku/bin:/usr/local/share/npm/bin:/usr/local/bin:/Applications/Postgres.app/Contents/Versions/9.3/bin:/usr/local/heroku/bin:/Users/nicholashaley/.rbenv/shims:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

I can confirm it is in the path echo $PATH yields /Users/nicholashaley/.rbenv/shims:/Users/nicholashaley/.rbenv/bin:/Applications/Postgres.app/Contents/Versions/9.3/bin:/usr/local/heroku/bin:/usr/local/share/npm/bin:/usr/local/bin:/Applications/Postgres.app/Contents/Versions/9.3/bin:/usr/local/heroku/bin:/Users/nicholashaley/.rbenv/shims:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin

我也可以确认节点已经安装 node -v 产生 v0.12.2

I can also confirm that node has been installed node -v yields v0.12.2

有什么想法吗?我晕了

推荐答案

不是答案,但可能是解决方案...

Not an answer, but maybe a solution...

通过brew卸载节点:brew uninstall node

Uninstall Node via brew: brew uninstall node

然后从 https://nodejs.org/en/download/ 下载 Node 并安装.

Then download Node from https://nodejs.org/en/download/ and install.

npm 然后应该正常工作".

npm should then "just work".

这篇关于安装节点后找不到 NPM 命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆