canonical_url: https://yycode.net/docs/en/nodejs-setup
lang: en
updated_at: 2026-07-04T13:33:48.616Z
source_html: https://yycode.net/docs/en/nodejs-setup

# Node.js Environment Installation Guide

Claude Code, Gemini CLI, Codex, and related tools all depend on the Node.js runtime. Please complete this step first.

## Windows

- **Method 1: Official download (recommended)**
  Go to the [Node.js official website](https://nodejs.org/zh-cn/download/) to download the LTS version, then double-click the installer and follow the prompts to complete installation.
- ![](https://r2.bozhouai.com/dragoncode/file-20260317105358821.png)
After downloading, keep clicking Next until installation is complete.

- **Method 2: Use Chocolatey**
  ```bash
  choco install nodejs-lts
  ```
- **Method 3: Use Scoop**
  ```bash
  scoop install nodejs-lts
  ```

## macOS

- **Method 1: Use Homebrew (recommended)**
  ```bash
  brew install node
  ```
- **Method 2: Official download**
  Go to the [Node.js official website](https://nodejs.org/zh-cn/download/) to download the macOS installer.

## Linux

- **Ubuntu / Debian**
  ```bash
  curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
  sudo apt-get install -y nodejs
  ```
- **CentOS / RHEL**
  ```bash
  curl -fsSL https://rpm.nodesource.com/setup_lts.x | sudo bash -
  sudo yum install -y nodejs
  ```

## Verify the Installation

```bash
node --version
npm --version
```

If both commands output version numbers, the installation was successful.

## Switch npm Registry Mirror (for environments without a proxy)

If dependency installation is slow or times out, run the following command to switch to a domestic mirror:

```bash
npm config set registry https://registry.npmmirror.com
```

Verify whether the switch succeeded:

```bash
npm config get registry
```

If the output is `https://registry.npmmirror.com`, it has taken effect.
