[英]zsh: command not found: npm
我剛剛使用以下命令安裝了 Node 和 Yarn:
brew install node
brew install yarn --without-node
node -v
v11.8.0
-a node
node is /usr/local/bin/node
yarn -v
1.13.0
type -a yarn
yarn is /usr/local/bin/yarn
但是,如果我在終端npm
中寫入“zsh:找不到命令:npm”
在我的: ~/.zshrc
我有:
ZSH=$HOME/.oh-my-zsh
# You can change the theme with another one:
# https://github.com/robbyrussell/oh-my-zsh/wiki/themes
ZSH_THEME="robbyrussell"
# Useful plugins for Rails development with Sublime Text
plugins=(gitfast last-working-dir common-aliases sublime zsh-syntax-highlighting history-substring-search)
# Prevent Homebrew from reporting - https://github.com/Homebrew/brew/blob/master/share/doc/homebrew/Analytics.md
export HOMEBREW_NO_ANALYTICS=1
# Actually load Oh-My-Zsh
source "${ZSH}/oh-my-zsh.sh"
unalias rm # No interactive rm by default (brought by plugins/common-aliases)
# Load rbenv if installed
export PATH="${HOME}/.rbenv/bin:${PATH}"
type -a rbenv > /dev/null && eval "$(rbenv init -)"
# Rails and Ruby uses the local `bin` folder to store binstubs.
# So instead of running `bin/rails` like the doc says, just run `rails`
# Same for `./node_modules/.bin` and nodejs
export PATH="./bin:./node_modules/.bin:${PATH}:/usr/local/sbin"
# Store your own aliases in the ~/.aliases file and load the here.
[[ -f "$HOME/.aliases" ]] && source "$HOME/.aliases"
# Encoding stuff for the terminal
export LANG=en_US.UTF-8
export LC_ALL=en_US.UTF-8
我嘗試使用本指南卸載並重新安裝 Node 和 Yarn: How do I completely uninstall Node.js, and reinstall from beginning (Mac OS X)
但我仍然遇到同樣的錯誤。
當我在source ~/.bash_profile
的開頭添加source ~/.bash_profile
時它對我~/.zshrc
,我還必須刪除
test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"
在~/.bash_profile
。 這是我不小心從 iTerm2 安裝的 shell 集成。
通過完全卸載Node並通過網站(而不是通過終端)安裝來解決它
通過運行brew uninstall node
並從他們的網站下載安裝 .pkg 的最新節點來解決它。
通過使用 nvm 選擇節點版本來解決。
nvm ls
然后
nvm use _version_code
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.