外观
Linux 平台安装 Node.js 环境 🐧 Linux
三大 AI 编程工具的必备运行环境
💡 重要说明
Claude Code、CodeX 和 Gemini CLI 都需要 Node.js 18+ 运行环境。如果您已安装 Node.js 18 或更高版本,可跳过本章节。
验证命令:node -v
Ubuntu/Debian 发行版
使用 NodeSource 仓库(推荐)
bash
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs验证安装
bash
node --version
npm --versionCentOS/RHEL/Fedora 发行版
使用 NodeSource 仓库
bash
curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash -
sudo yum install -y nodejs使用 NVM 推荐
NVM 可以方便地管理多个 Node.js 版本:
bash
# 安装 NVM
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
# 加载 NVM
source ~/.bashrc
# 安装最新 LTS 版本
nvm install --lts
# 验证安装
node --version
npm --version常见问题
npm 安装很慢/失败
可以使用国内镜像:
bash
# 设置淘宝镜像
npm config set registry https://registry.npmmirror.com
# 验证配置
npm config get registry权限问题
如果遇到 npm 全局安装权限问题,建议使用 NVM 管理 Node.js,避免权限冲突。
下一步
✅ 环境准备完成!现在您可以继续安装 Claude Code、CodeX 或 Gemini CLI 了。
