> ## Documentation Index
> Fetch the complete documentation index at: https://docs.jiji.cc/llms.txt
> Use this file to discover all available pages before exploring further.

# Node.js 环境配置

> 通过 npm 安装 Codex、Gemini CLI 前的 Node.js 环境准备。

Gemini CLI，以及通过 npm 方式安装的 Codex，需要 Node.js 18 或更高版本。Claude Code 使用官方安装脚本安装时不需要 Node.js。

## 检查是否已安装

```bash theme={null}
node -v
npm -v
```

能输出版本号且 Node.js 版本不低于 `v18`，即可跳过本页。

## 安装 Node.js

<Tabs>
  <Tab title="macOS">
    **方法一：Homebrew（推荐）**

    ```bash theme={null}
    brew install node
    ```

    **方法二：官方安装包**

    从 [Node.js 官网](https://nodejs.org/zh-cn/download) 下载 LTS 版本的 `.pkg` 安装包，双击安装。
  </Tab>

  <Tab title="Windows">
    **方法一：WinGet（推荐）**

    ```powershell theme={null}
    winget install OpenJS.NodeJS.LTS
    ```

    **方法二：官方安装包**

    从 [Node.js 官网](https://nodejs.org/zh-cn/download) 下载 LTS 版本的 `.msi` 安装包，按提示安装。
  </Tab>

  <Tab title="Linux">
    推荐使用 [nvm](https://github.com/nvm-sh/nvm) 安装，不需要 `sudo`：

    ```bash theme={null}
    curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.3/install.sh | bash
    # 重新打开终端后执行
    nvm install --lts
    ```
  </Tab>
</Tabs>

安装完成后，**打开一个新的终端窗口**，再运行 `node -v` 确认安装成功。

## 使用国内镜像

npm 默认从海外源下载，速度较慢时可以切换到国内镜像：

```bash theme={null}
npm config set registry https://registry.npmmirror.com
```

也可以只在安装时临时指定，例如：

```bash theme={null}
npm i -g @openai/codex --registry=https://registry.npmmirror.com
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.