我很难使npm命令正常工作,但是不幸的是,我对Unix的了解不足以独自解决这个问题。我所做的只是brew install node,并且出现以下错误:
brew install node
当我型npm我得到zsh: command not found: npm
npm
zsh: command not found: npm
进一步研究此问题,我发现此堆栈溢出答案:
在zsh中安装npm后找不到命令
按照其建议,我尝试将其添加export PATH=/usr/local/share/npm/bin:$PATH到我的.zshrc文件中。键入时仍然出现相同的错误npm
export PATH=/usr/local/share/npm/bin:$PATH
我可以确认这是在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
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
我还可以确认节点已安装node -v率v0.12.2
node -v
v0.12.2
有任何想法吗?我很困惑
不是答案,而是解决方案…
通过brew卸载Node: brew uninstall node
brew uninstall node
然后从https://nodejs.org/en/download/下载Node 并安装。
npm然后应该“工作”。