Skip to content

macOS 平台

在 macOS 上安装 Node.js 运行环境。推荐使用 Node.js 20 LTS 或更新版本。

方法一:Homebrew(推荐)

bash
# 安装 Homebrew(如未安装)
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# 安装 Node.js LTS
brew install node@20

# 验证
node -v
npm -v

方法二:nvm(推荐开发者)

bash
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash

# 重启终端后
nvm install 20
nvm use 20
nvm alias default 20

换源

bash
npm config set registry https://registry.npmmirror.com

下一步

和谐、友善、互助、开心