终端与Home Brew安装后无法识别NVM
我通过自制软件安装了nvm,但是当我运行nvm -v或nvm --version窗体终端时,收到未找到消息命令:nvm.当我在finder和cmd + shift +中查看时.我可以看到〜/.nvm文件夹.
I installed nvm via homebrew, but when I run nvm -v or nvm --version form terminal I receive the message command not found: nvm. When I look in finder and cmd+shift+. I can see the ~/.nvm folder.
最初,我的用户目录中没有.bash_profile,因此我在这篇文章中添加了一个和识别nvm的命令:轻松安装nvm.nvm:找不到命令
Initially I did not have a .bash_profile in my user directory, so I added one and the command to recognize nvm per this post: Brew install nvm. nvm: command not found
但是,这不能解决问题.我以前在安装nvm时还没有遇到过这个问题,这可能是怎么回事?
However, that did not resolve the issue. I've not had this issue with an nvm install before, What could be going on here?
我正在使用macOS Catalina 10.15.6
I am on macOS Catalina 10.15.6
在安装nvm之后,我面临着同样的问题.每当我的iTerm/终端重新启动时,nvm就消失了.
I was facing the same issue after installing nvm. Whenever my iTerm / terminal restarts, nvm is gone.
我按照步骤进行操作.
安装后,更新Homebrew软件包列表并安装NVM.
After installing it, update the Homebrew package list and install NVM.
brew update
brew install nvm
接下来,为NVM创建一个目录.
Next, create a directory for NVM.
mkdir ~/.nvm
现在将这些行添加到〜/.bash_profile中(对于macOS Catalina或更高版本,将其添加到〜/.zshrc中)
Now add these lines to ~/.bash_profile ( or ~/.zshrc for macOS Catalina or later)
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
现在,回显$ NVM_DIR应该返回您的NVM目录
Echoing $NVM_DIR should now return your NVM directory
:$ echo $NVM_DIR
/Users/username/.nvm
现在运行 nvm -v
会返回nvm的选项.要查看可以安装哪些节点版本,请运行:
Now running nvm -v
should return nvm’s options.
To see what Node versions are available to install run:
nvm ls-remote
对我来说,我只需要最新版本的Node 11,就可以运行
For me, I just needed the latest point release of Node version 11 so I ran
nvm install 11
安装后,您可以验证安装了什么
After installing you can verify what is installed with
nvm ls
如果您有多个版本,并且想要指定要使用的版本,只需使用:
If you have multiple versions and you want to specify which version you would like to use, simply use:
nvm use 11
使用节点版本11.切换回,例如,版本12就像 nvm use 12一样简单.
切换到节点版本11后,我的所有软件包都已正确安装.
to use Node version 11.
Switching back to, let’s say, version 12 would be as easy as nvm use 12.
After switching to node version 11, all my packages installed properly.