> 技术文档 > 猫头虎 分享 | 如何下载Claude Code 、安装教程、配置指南、Windows & macOS、 Linux (Ubuntu/Debian) 平台 使用全攻略

猫头虎 分享 | 如何下载Claude Code 、安装教程、配置指南、Windows & macOS、 Linux (Ubuntu/Debian) 平台 使用全攻略

猫头虎 分享 | 如何下载Claude Code 、安装教程配置指南Windows & macOS Linux (Ubuntu/Debian) 平台 使用全攻略 🚀

在这篇《Claude Code 安装配置教程》中,你将学到如何在 WindowsmacOS 以及 Linux (Ubuntu/Debian) 平台下一步步完成 Node.js 环境搭建Anthropic Claude Code 安装Auth Token 获取与环境变量配置,并在终端中快速启动你的 AI 编程助手。本文涵盖 Node.js ≥18.0 安装npm 全局安装 Claude CodeANTHROPIC_AUTH_TOKENANTHROPIC_BASE_URL 两大核心环境变量设置、一键启动实战演示,帮你快速上手 Claude Code 提升开发效率,轻松搞定代码补全、重构和文档生成!


猫头虎 分享 | 如何下载Claude Code 、安装教程、配置指南、Windows & macOS、 Linux (Ubuntu/Debian) 平台 使用全攻略

文章目录

    • 1️⃣ 安装 Node.js(已安装可跳过)
      • Ubuntu / Debian 用户
      • macOS 用户
    • 2️⃣ 安装 Claude Code
    • 3️⃣ 开始使用
      • 1. 获取 Auth Token
      • 2. 配置 API 地址
      • 3. 在项目目录下运行
    • 4️⃣ 配置环境变量(推荐)

1️⃣ 安装 Node.js(已安装可跳过)

前提:确保 Node.js 版本 ≥ 18.0

Ubuntu / Debian 用户

# Ubuntu / Debian 用户curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo bash -sudo apt-get install -y nodejsnode --version

macOS 用户

# macOS 用户sudo xcode-select --install/bin/bash -c \"$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\"brew install nodenode --version

如果输出的版本号 v18.x.x 或更高,即表示 Node.js 安装并生效。


2️⃣ 安装 Claude Code

使用 npm 全局安装官方 CLI 包:

npm install -g @anthropic-ai/claude-codeclaude --version

安装成功后,claude --version 应显示当前安装的 @anthropic-ai/claude-code 版本号。


3️⃣ 开始使用

1. 获取 Auth Token

  • 登录 Anthropic 平台
  • 进入 “API 令牌” 页面,点击 添加令牌
  • 复制以 sk- 开头的 ANTHROPIC_AUTH_TOKEN

建议额度选择 无限额度,名称随意,其它保持默认。

2. 配置 API 地址

  • 设定 ANTHROPIC_BASE_URL=https://anyrouter.top,这是本站中转服务地址,与主站接口一致。

3. 在项目目录下运行

cd your-project-folderexport ANTHROPIC_AUTH_TOKEN=sk-...export ANTHROPIC_BASE_URL=https://anyrouter.topclaude
  • 选择主题 → Enter
  • 确认安全须知 → Enter
  • 使用默认 Terminal 配置 → Enter
  • 信任工作目录 → Enter

完成后,即可在终端中与 Claude Code AI 编程搭档实时对话,开始代码补全、生成与重构。🚀


4️⃣ 配置环境变量(推荐)

为了避免每次手动输入 export,建议将环境变量写入 Shell 启动脚本。

# 写入 ~/.bash_profileecho -e \'\\nexport ANTHROPIC_AUTH_TOKEN=sk-...\' >> ~/.bash_profileecho -e \'\\nexport ANTHROPIC_BASE_URL=https://anyrouter.top\' >> ~/.bash_profile# 写入 ~/.bashrcecho -e \'\\nexport ANTHROPIC_AUTH_TOKEN=sk-...\' >> ~/.bashrcecho -e \'\\nexport ANTHROPIC_BASE_URL=https://anyrouter.top\' >> ~/.bashrc# 写入 ~/.zshrcecho -e \'\\nexport ANTHROPIC_AUTH_TOKEN=sk-...\' >> ~/.zshrcecho -e \'\\nexport ANTHROPIC_BASE_URL=https://anyrouter.top\' >> ~/.zshrc

保存后重启终端,或执行 source ~/.bash_profile / source ~/.zshrc

然后,任何时候只需在项目目录执行:

cd your-project-folderclaude

即可立刻调用 Claude Code,畅享 AI 编程带来的高效体验!


猫头虎贴士:

  • 若因网络或权限问题无法访问 https://anyrouter.top,请检查防火墙或使用稳定 “IP”。
  • 关注 @anthropic-ai/claude-code 官方仓库,获取最新功能与版本更新。

长按收藏🔖,转发分享给更多开发者,让 AI 助手陪你一起解锁高效编程新时代!

考研知识分享