Skip to main content

环境

系统版本至少为 MacOS12

非最新的系统不保证其成功性

校验git版本,未安装会提示下载常用工具包
git --version

Brew 官网

下载Brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
添加环境变量
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.bash_profile
添加环境变量
echo 'export PATH="/opt/homebrew/bin:$PATH"' >> ~/.zshrc
重载环境变量
source ~/.bash_profile && source ~/.zshrc

使用nvm对Node.js进行安装和版本管理,方便切换版本进行开发

安装nvm
brew install nvm
为bash添加环境
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.bash_profile
echo '[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"' >> ~/.bash_profile
echo '[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm"' >> ~/.bash_profile
为zshrc添加环境
echo 'export NVM_DIR="$HOME/.nvm"' >> ~/.zshrc
# This loads nvm
echo '[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh"' >> ~/.zshrc
# This loads nvm bash_completion
echo '[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm"' >> ~/.zshrc
刷新环境
source ~/.bash_profile && source ~/.zshrc
安装NodeJS@18.20.3
nvm install 18.20.3
nvm use 18.20.3
node -v
npm -v

出现意外?阅读常见问题