XuanShu API
Install Node.js
Install Node.js 22 or newer on Windows, macOS, and Linux, then verify the node and npm commands. Claude Code, Codex, and Gemini CLI all depend on this environment.
1. Install Node.js (22 or newer) for your system
Pick your system and run the commands. Any one of the three Windows options is enough.
# 官网安装包(推荐)
# 打开 https://nodejs.org 下载 LTS 安装包,双击按提示安装
node --version
npm --versionchoco install nodejs-lts
node --version
npm --versionscoop install nodejs-lts
node --version
npm --versionbrew install node
node --version
npm --versioncurl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
node --version
npm --version2. Verify the installation
The environment is ready when both node --version and npm --version print a version. Node.js 22 or newer is required. If the command is not found, close and reopen the terminal, because PATH changes only apply to newly opened terminals.
4. Troubleshooting
| Symptom | Cause | Resolution |
|---|---|---|
| Command not found | PATH was not refreshed after installation, or the installer did not update it. | Close every terminal and reopen one; on Windows, sign out and back in. |
| npm permission error | Global packages installed with sudo on Linux belong to root. | Prefer nvm to manage Node.js so global installs never need sudo. |
| Version too old | Distribution repositories usually ship an older Node.js. | Reinstall through NodeSource or Homebrew as shown above, and confirm the version is at least 22. |