本文将针对 Mac 上进行常见的 Homebrew、Node.js、Git 等的基本安装与环境配置。
打开终端,执行以下命令来安装 Homebrew:
/bin/zsh -c "$(curl -fsSL https://gitee.com/cunkai/HomebrewCN/raw/master/Homebrew.sh)"友情提示:根据命令安装即可,镜像加速推介选择
中科大国内源。
检查 Homebrew 是否成功安装:
brew --version使用 Homebrew 安装 Node.js:
brew install node
安装完成后,验证安装是否成功:
node -v
npm -v如果需要使用 pnpm(比 npm 更快速的包管理工具),可以使用以下命令安装:
brew install pnpm淘宝镜像源
# NPM
npm config set registry https://registry.npmmirror.com/
# PNPM
pnpm config set registry https://registry.npmmirror.com/
## 还原
npm config set registry https://registry.npmjs.org/
pnpm config set registry https://registry.npmjs.org/配置代理
# NPM
npm config set proxy http://127.0.0.1:10000
npm config set https-proxy http://127.0.0.1:10000
npm config delete proxy
npm config delete https-proxy
# PNPM
pnpm config set proxy http://127.0.0.1:10000
pnpm config set https-proxy https://127.0.0.1:10000
pnpm config delete proxy
pnpm config delete https-proxy使用 Homebrew 安装 Git:
brew install git配置 Git 用户名和邮箱:
git config --global user.name "Your Name"
git config --global user.email "youremail@example.com"
验证安装:
git --version# 配置全局代理
git config --global http.proxy http://127.0.0.1:10000
git config --global https.proxy http://127.0.0.1:10000
# 配置 Github 代理
git config --global http.https://github.com/.proxy http://127.0.0.1:10000 # 配置 Github 代理
git config --global https.https://github.com/.proxy http://127.0.0.1:10000 # 配置 Github 代理
# 删除代理配置
git config --global --unset http.proxy
git config --global --unset https.proxy 新环境开发环境构建时, pnpm 默认会忽略一些构建脚本,除非你明确批准它们。
Ignored build scripts: @tailwindcss/oxide, esbuild.
Run "pnpm approve-builds" to pick which dependencies should be allowed to run scripts.
# 按照提示选择即可
pnpm approve-builds配置 Mac 开发环境时,使用 Homebrew 可以大大简化安装和管理工具的过程。通过安装和配置这些常用开发工具,你可以快速开始你的开发工作。记得根据自己的项目需求调整工具和环境设置,并定期更新工具和依赖库。