我很欣赏这个问题被问过几次,但是没有一个答案能帮助我。
我对在终端上工作并不陌生,并且正在尝试在MacOS Catalina上使用nvm安装节点。我使用“ brew install nvm”成功安装了nvm,但是当我尝试运行“ nvm install 10.15.0”时,出现错误“ zsh:找不到命令:nvm”。
运行“ brew info nvm”给了我这个:
You should create NVM's working directory if it doesn't exist:
mkdir ~/.nvm
Add the following to ~/.zshrc or your desired shell
configuration file:
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm
[ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
You can set $NVM_DIR to any location, but leaving it unchanged from
/usr/local/opt/nvm will destroy any nvm-installed Node installations
upon upgrade/reinstall.
因此,我遵循了这些说明;我创建了NVM工作目录,并将配置添加到我的/.bash_profile shell中。这是使用'nano .bash_profile'运行时的.bash_profile文件:
# added by Anaconda3 2019.10 installer
# >>> conda init >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$(CONDA_REPORT_ERRORS=false '/Users/emilybradley/opt/anaconda3/b$
if [ $? -eq 0 ]; then
\eval "$__conda_setup"
else
if [ -f "/Users/emilybradley/opt/anaconda3/etc/profile.d/conda.sh" ]; then
. "/Users/emilybradley/opt/anaconda3/etc/profile.d/conda.sh"
CONDA_CHANGEPS1=false conda activate base
else
\export PATH="/Users/emilybradley/opt/anaconda3/bin:$PATH"
fi
fi
unset __conda_setup
# <<< conda init <<<
# virtualenvwrapper
export WORKON_HOME=$HOME/.virtualenvs
source "$(pyenv which virtualenvwrapper.sh)"
# RabbitMQ
export PATH=/usr/local/sbin:$PATH
export NVM_DIR="$HOME/.nvm"
[ -s "/usr/local/opt/nvm/nvm.sh" ] && . "/usr/local/opt/nvm/nvm.sh" # This loads nvm
[ -s "/usr/local/opt/nvm/etc/bash_completion.d/nvm" ] && . "/usr/local/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion
我已经重新启动了终端,但是仍然无法进行nvm安装。老实说,.bash_profile文件让我有些困惑,想知道这是否与PATH有关吗?
答案 0 :(得分:1)
这个问题已经回答了很多次了。
最近的这个问题对通过 brew 安装 nvm 有一个简单而直接的答案: simple solution
如果您使用或不使用 brew 进行安装,这个较旧的问题有更深入的解决方案和其他详细信息: detailed solutions