Node.js Environment Installation Guide
Claude Code, Codex CLI, Gemini CLI, and most API scripts depend on Node.js. It is recommended to install the LTS version, keeping the major version number at 18 or higher.
Windows
Method 1: Official Installer
Visit nodejs.org, download the LTS .msi installer, follow the "Next" prompts to complete the installation, and keep the option to automatically add to PATH.
Method 2: Chocolatey
choco install nodejs-lts -y
Method 3: Scoop
scoop install nodejs-lts
Verify after reopening PowerShell:
node --version
npm --version
macOS
Method 1: Homebrew (Recommended)
brew install node
node --version
npm --version
Method 2: Official Installer
Visit nodejs.org to download macOS .pkg, double-click to install, and then reopen the terminal.
Linux
Method 1: nvm (Recommended, no sudo required, supports multiple versions)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source ~/.bashrc # for zsh users use source ~/.zshrc
nvm install --lts
nvm use --lts
node --version
npm --version
Method 2: Package Manager
# Debian / Ubuntu
sudo apt update
sudo apt install -y nodejs npm
# Fedora
sudo dnf install -y nodejs npm
General Method for Installing the CLI
npm install -g <package-name>
If a permission error occurs, first check whether nvm or the current Node version is correctly effective. It is not recommended to directly use administrator privileges to overwrite system directories. After installation, use where node (Windows) or which node (macOS/Linux) to verify the path.