1.安装Homebrew https://brew.idayer.com
打开终端运行
/bin/bash -c "$(curl -fsSL https://gitee.com/ineo6/homebrew-install/raw/master/install.sh)"
2.安装nvm:安装成功Homebrew
brew install nvm
在home目录中为NVM创建一个文件夹
mkdir ~/.nvm
配置环境变量 编辑一下配置文件
vim ~/.bash_profile
然后在bash_prifile中添加以下几行i进入编辑模式,esc退出编辑模式,:wq保存并退出
export NVM_DIR=/.nvm
source $(brew --profix nvm)/nvm.sh
执行命令将变量加载到shell环境中
source ~/.bash_profile
如果命令行关闭重新打开新窗口有问题,运行vim ~/.zshr,在里面添加source ~/.bash_profile