CLI Environment Setup — Install Claude Code, Codex & Gemini CLI
How to set up your environment for AI CLI tools. Install Node.js and globally install Claude Code CLI, OpenAI Codex CLI, and Gemini CLI on Windows and macOS before configuring an API key.
Environment check
Works on Windows, macOS, and Linux (adjust paths if needed).
(1) Node.js
npm list -g --depth=0
- OK: output or empty list.
- Fail: “command not found” → install Node.js LTS (18+), reopen the terminal, retry.
node -v
npm -v
(2) Install CLIs
npm i -g @anthropic-ai/claude-code@latest
npm i -g @openai/codex@latest
npm i -g @google/gemini-cli@latest
Install only the tools you need.
(3) First run (creates config dirs)
Run each command once so
~/.claude,~/.codex, and~/.geminiare created.
claude
codex
gemini
Exit with Ctrl+C or the on-screen prompt when you see a UI or wizard.
(4) Next
With an API key:
Install issues
| Issue | Fix |
|---|---|
EACCES |
Avoid sudo npm -g; use nvm or fix npm prefix |
| Corporate proxy | Set HTTPS_PROXY / npm proxy |
| Old version | npm i -g package@latest |