系统要求与环境准备

安装 Claude Code 前的系统要求和环境配置指南

系统要求

在安装 Claude Code 之前,确保你的系统满足以下要求。

操作系统

系统最低版本
WindowsWindows 10 64位 或更高
macOSmacOS 10.15 (Catalina) 或更高
LinuxUbuntu 18.04 或其他兼容发行版

硬件要求

项目最低要求推荐配置
CPU4 核处理器-
内存8GB RAM16GB 或更高
磁盘空间1GB 可用空间-
网络稳定的互联网连接-

软件要求

软件最低版本用途
Node.js16.0+命令行工具运行环境
npm8.0+包管理器
Git2.0+代码管理和插件安装

环境准备

安装 Node.js 和 npm

Claude Code 的命令行工具依赖 Node.js 和 npm。

检查已安装版本

# 检查 Node.js 版本
node --version

# 检查 npm 版本
npm --version

如果版本满足要求(Node.js ≥ 16.0,npm ≥ 8.0),可跳过安装步骤。

方式一:官方安装包

  1. 访问 Node.js 官网
  2. 下载 LTS(长期支持)版本
  3. 运行安装程序完成安装
  4. 重新打开终端验证版本

方式二:使用 nvm(推荐)

使用 Node 版本管理器可以方便地管理多个 Node.js 版本。

macOS / Linux:

# 安装 nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.5/install.sh | bash

# 重新打开终端后,安装 Node.js LTS 版本
nvm install --lts
nvm use --lts

# 验证安装
node --version
npm --version

安装 Git

检查已安装版本

git --version

如果版本 ≥ 2.0,可跳过安装步骤。

macOS

# 使用 Homebrew 安装(推荐)
brew install git

# 或使用 Xcode Command Line Tools
xcode-select --install

Windows

  1. 访问 Git 官网
  2. 下载 Windows 安装程序
  3. 运行安装程序(建议使用默认配置)

Linux

# Ubuntu / Debian
sudo apt-get update
sudo apt-get install git

# CentOS / RHEL
sudo yum install git

# Fedora
sudo dnf install git

配置 Git

安装完成后,配置用户名和邮箱(用于代码提交):

git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

环境验证

运行以下命令验证环境是否准备就绪:

node --version   # 应 ≥ 16.0
npm --version    # 应 ≥ 8.0
git --version    # 应 ≥ 2.0

所有命令正常输出且版本符合要求,即可开始安装 Claude Code。

常见问题

Node.js 安装失败

问题:运行 node --version 显示 "command not found"

解决方案

  • 检查安装过程是否有错误
  • 确保 Node.js 安装路径已添加到系统环境变量
  • 重新启动终端
  • 尝试使用 nvm 重新安装

npm 安装包失败

问题:网络错误或权限错误

解决方案

  • 检查网络连接
  • 使用国内镜像:npm config set registry https://registry.npmmirror.com
  • 权限错误时使用 sudo(Linux/macOS)或管理员权限(Windows)

Git 配置错误

问题:提交时显示用户名或邮箱未配置

解决方案

  • 检查配置:git config --list
  • 重新配置用户名和邮箱
  • 如全局配置无效,尝试在项目目录进行本地配置

高级配置

使用 yarn 或 pnpm

Claude Code 也支持其他包管理器:

# 安装 yarn
npm install -g yarn

# 安装 pnpm
npm install -g pnpm

配置 npm 镜像

提高国内下载速度:

# 使用淘宝镜像
npm config set registry https://registry.npmmirror.com

# 恢复官方镜像
npm config set registry https://registry.npmjs.org/

配置 HTTP 代理

如需使用代理:

npm 代理:

# 设置代理
npm config set proxy http://proxy.example.com:8080
npm config set https-proxy http://proxy.example.com:8080

# 取消代理
npm config delete proxy
npm config delete https-proxy

Git 代理:

# 设置代理
git config --global http.proxy http://proxy.example.com:8080
git config --global https.proxy http://proxy.example.com:8080

# 取消代理
git config --global --unset http.proxy
git config --global --unset https.proxy

On this page