1.homeBrew安装
终端输入
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
check是否成功
brew --version
2.使用 Homebrew 安装nvm
设置镜像源
npm config set registry https://registry.npm.taobao.org
homeBrew安装任何软件,brew install 软件名字,例如,brew install wget
要安装nvm 则输入命令
brew install 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 "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm
[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/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
/opt/homebrew/opt/nvm will destroy any nvm-installed Node installations
upon upgrade/reinstall.
Type `nvm help` for further information.
依据提示的步骤,进行创建文件夹 和编辑文档
mkdir ~/.nvm
vi ~/.zshrc
编辑保存之后,source ~/.zshrc
检查配置是否生效
echo $NVM_DIR
check版本
nvm -v
3.node安装
nvm install 版本号
node -v
npm -v
看到 版本号证明安装成功