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命令工作,不幸的是我对unix的了解并不足以解决这个问题。我所做的就是brew install节点,我收到以下错误:
When I type npm
I get zsh: command not found: npm
当我键入npm时,我得到zsh:command not found:npm
Looking into this issue more I found this stack overflow answer:
仔细研究这个问题,我发现这个堆栈溢出答案:
Command not found after npm install in zsh
在zsh中安装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
根据它的建议,我尝试将export PATH = / usr / local / share / npm / bin:$ PATH添加到我的.zshrc文件中。键入npm时仍会出现相同的错误
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
我可以确认它是在路径echo $ PATH产量/Users/nicholashaley/.rbenv/shims:/Users/nicholashaley/.rbenv/bin:/Applications/Postgres.app/Contents/Versions/9.3/bin:/usr/本地/ Heroku的/ bin中:在/ usr / local / share下/ NPM /斌:在/ usr / local / bin目录:/Applications/Postgres.app/Contents/Versions/9.3/bin:在/ usr /本地/ Heroku的/ bin中:/用户/nicholashaley/.rbenv/shims:/usr/local/bin:/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/箱子
I can also confirm that node has been installed node -v
yields v0.12.2
我还可以确认节点已经安装了节点-v yield v0.12.2
Any ideas? I'm stumped
有任何想法吗?我很难过
5 个解决方案
#1
33
Not an answer, but maybe a solution...
不是答案,但可能是一个解决方案......
Uninstall Node via brew: brew uninstall node
通过brew:brew uninstall节点卸载Node
Then download Node from https://nodejs.org/en/download/ and install.
然后从https://nodejs.org/en/download/下载Node并安装。
npm
should then "just work".
那么npm应该“正常工作”。
#2
22
I came across to this thread with the same problem but finally below is what worked for me which is without sudo
我遇到了同样问题的这个帖子,但最后下面是对我有用的,没有sudo
$ brew update
$ brew uninstall node
$ brew install node
$ chown -R YourUserName /usr/local/lib/node_modules/
$ brew postinstall node #This what the important step
#3
18
Ok this is what worked for me:
好的,这对我有用:
$ brew update
$ brew uninstall node
$ brew install node
$ sudo brew postinstall node #This what the important step
#4
7
In case this never got solved, this is what worked for me:
如果这从未得到解决,这对我有用:
brew uninstall node
- brew卸载节点
brew install node
- brew安装节点
-
brew doctor
and see what needs to be pruned. My problem was there was a non-brew place where I had changed my install location for npm packages because I was trying to get an npm package to install for me. That was a mistake (having forgotten I initially installed node and npm through brew but now brew could no longer reach the npm install directory nor could it change or delete it). Sobrew prune
didn't work even though the symlinks were supposedly deleted but it reminded me that I had changed the npm install location. And that brings us to:酿造医生,看看需要修剪什么。我的问题是有一个非酿造的地方我改变了我的npm包的安装位置,因为我试图为我安装一个npm包。这是一个错误(忘记我最初安装节点和npm通过brew,但现在brew不再能够到达npm安装目录,也无法更改或删除它)。所以即使符号链接被删除,brew剪辑也不起作用,但它提醒我,我已经更改了npm安装位置。这带来了:
-
Delete those directories
删除这些目录
-
brew postinstall node
- brew postinstall节点
Hope it helps.
希望能帮助到你。
#5
0
Anyone on the LTS release use the following command instead:
LTS版本中的任何人都使用以下命令:
brew postinstall node@6
#1
33
Not an answer, but maybe a solution...
不是答案,但可能是一个解决方案......
Uninstall Node via brew: brew uninstall node
通过brew:brew uninstall节点卸载Node
Then download Node from https://nodejs.org/en/download/ and install.
然后从https://nodejs.org/en/download/下载Node并安装。
npm
should then "just work".
那么npm应该“正常工作”。
#2
22
I came across to this thread with the same problem but finally below is what worked for me which is without sudo
我遇到了同样问题的这个帖子,但最后下面是对我有用的,没有sudo
$ brew update
$ brew uninstall node
$ brew install node
$ chown -R YourUserName /usr/local/lib/node_modules/
$ brew postinstall node #This what the important step
#3
18
Ok this is what worked for me:
好的,这对我有用:
$ brew update
$ brew uninstall node
$ brew install node
$ sudo brew postinstall node #This what the important step
#4
7
In case this never got solved, this is what worked for me:
如果这从未得到解决,这对我有用:
brew uninstall node
- brew卸载节点
brew install node
- brew安装节点
-
brew doctor
and see what needs to be pruned. My problem was there was a non-brew place where I had changed my install location for npm packages because I was trying to get an npm package to install for me. That was a mistake (having forgotten I initially installed node and npm through brew but now brew could no longer reach the npm install directory nor could it change or delete it). Sobrew prune
didn't work even though the symlinks were supposedly deleted but it reminded me that I had changed the npm install location. And that brings us to:酿造医生,看看需要修剪什么。我的问题是有一个非酿造的地方我改变了我的npm包的安装位置,因为我试图为我安装一个npm包。这是一个错误(忘记我最初安装节点和npm通过brew,但现在brew不再能够到达npm安装目录,也无法更改或删除它)。所以即使符号链接被删除,brew剪辑也不起作用,但它提醒我,我已经更改了npm安装位置。这带来了:
-
Delete those directories
删除这些目录
-
brew postinstall node
- brew postinstall节点
Hope it helps.
希望能帮助到你。
#5
0
Anyone on the LTS release use the following command instead:
LTS版本中的任何人都使用以下命令:
brew postinstall node@6