# 亚太地区加速访问教程

> 亚太地区用户安装 Node.js、Git、配置 npm 腾讯云镜像及 macOS Homebrew 镜像加速指南。

亚太地区网络环境下，直接从官方源下载 Node.js 包、Git 以及通过 npm/Homebrew 安装依赖时速度较慢甚至超时。本文介绍如何使用亚太地区镜像源加速这些工具的安装与使用。

## 安装 Node.js

### Windows

推荐使用清华大学镜像站下载 Node.js 安装包：

1. 访问 [清华大学 Node.js 镜像](https://mirrors.tuna.tsinghua.edu.cn/nodejs-release/v24.0.0/)
2. 下载 `node-v24.0.0-x64.msi` 安装包
3. 双击运行安装，一路默认即可

或者直接访问 [Node.js 官网](https://nodejs.org/)，选择左侧 LTS 版本下载。

安装完成后打开命令行验证：

```bash
node -v
npm -v
```

### macOS

推荐使用 Homebrew 安装（Homebrew 镜像配置见下文）：

```bash
brew install node
```

或使用 [nvm](https://github.com/nvm-sh/nvm) 管理多版本：

```bash
curl -o- https://github.com/nvm-sh/nvm/raw/main/install.sh | bash
source ~/.zshrc
nvm install --lts
```

### Linux

```bash
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs
```

## 安装 Git

### Windows

推荐从清华大学镜像站下载：

1. 下载 [Git-2.53.0.3-64-bit.exe（清华镜像）](https://mirrors.tuna.tsinghua.edu.cn/github-release/git-for-windows/git/LatestRelease/Git-2.53.0.3-64-bit.exe)
3. 双击安装，保持默认选项即可

安装完成后验证：

```bash
git --version
```

### macOS

macOS 自带 Git，也可通过 Homebrew 安装最新版：

```bash
brew install git
```

### Linux (Debian/Ubuntu)

```bash
sudo apt-get update
sudo apt-get install -y git
```

## 配置 npm 腾讯云镜像

npm 默认从 `registry.npmjs.org` 下载包，亚太地区访问较慢。切换到腾讯云镜像可以显著提升速度。

### 全局设置镜像源

```bash
npm config set registry https://mirrors.cloud.tencent.com/npm/
```

### 验证配置

```bash
npm config get registry
```

应显示：`https://mirrors.cloud.tencent.com/npm/`

### 临时使用（不修改全局配置）

在安装命令后加 `--registry` 参数：

```bash
npm install -g @anthropic-ai/claude-code --registry https://mirrors.cloud.tencent.com/npm/
```

### 恢复官方源

```bash
npm config set registry https://registry.npmjs.org/
```

## macOS Homebrew 镜像加速

Homebrew 默认从 GitHub 拉取，亚太地区速度较慢。推荐使用清华大学镜像源。

### 设置 Homebrew 镜像

将以下内容追加到 `~/.zshrc`：

```bash
{
echo ''
echo '# Homebrew 清华镜像'
echo 'export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"'
echo 'export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"'
echo 'export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"'
echo 'export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"'
echo 'export HOMEBREW_PIP_INDEX_URL="https://pypi.tuna.tsinghua.edu.cn/simple"'
} >> ~/.zshrc
```

使配置生效：

```bash
source ~/.zshrc
```

### 验证

```bash
brew update
```

如果更新速度明显加快，说明镜像已生效。

### 首次安装 Homebrew

如果尚未安装 Homebrew，可使用清华镜像加速安装：

```bash
export HOMEBREW_BREW_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/brew.git"
export HOMEBREW_CORE_GIT_REMOTE="https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/homebrew-core.git"
export HOMEBREW_API_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api"
export HOMEBREW_BOTTLE_DOMAIN="https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles"
/bin/bash -c "$(curl -fsSL https://mirrors.tuna.tsinghua.edu.cn/git/homebrew/install/raw/HEAD/install.sh)"
```

### 恢复官方源

```bash
unset HOMEBREW_API_DOMAIN
unset HOMEBREW_BOTTLE_DOMAIN
unset HOMEBREW_BREW_GIT_REMOTE
unset HOMEBREW_CORE_GIT_REMOTE
unset HOMEBREW_PIP_INDEX_URL
git -C "$(brew --repo)" remote set-url origin https://github.com/Homebrew/brew
```

## pip 镜像加速（可选）

如果使用 Python SDK，推荐配置 pip 腾讯云镜像：

```bash
pip config set global.index-url https://mirrors.cloud.tencent.com/pypi/simple
```

## Git Clone 加速（可选）

对于 GitHub 上的仓库，可以使用镜像加速克隆：

```bash
# 使用 GitHub 代理
git clone https://gh.llkk.cc/https://github.com/用户名/仓库名.git
```

> 加速地址来自第三方 GitHub Proxy，请确认项目名和版本号一致。

本文是 https://llmoxy.com/docs/code-tutorials/apac-speedup 的 markdown 版本。
