If you want to install Claude CLI and start using Anthropic’s agentic coding assistant from your terminal, the whole process takes about five minutes on any modern system. The tool, officially called Claude Code, runs on macOS, Linux, and Windows (via WSL or PowerShell with a native installer).
Claude Code is one of the most capable AI developer tools available right now, letting you delegate refactoring, debugging, and multi-file edits directly from your shell. This guide walks through every step: prerequisites, installation, authentication, your first run, and fixing the errors people hit most often.
npm install -g @anthropic-ai/claude-code. Verify with claude --version, authenticate with claude login or the ANTHROPIC_API_KEY environment variable, and start a session by running claude in your project folder.Prerequisites before you install Claude CLI
Claude Code is distributed as an npm package, so you need Node.js 18 or newer installed first. You can check your current version with a single command.
node --version
If the command prints something below v18, or nothing at all, install or upgrade Node.js before continuing. We strongly recommend using a version manager (nvm on macOS/Linux, nvm-windows on Windows) instead of the system package manager, because it avoids the permission headaches covered later in this guide.
You also need an Anthropic account with either a Claude subscription (Pro or Max) or an Anthropic API key with billing enabled. Claude Code will ask which one you want to use the first time you authenticate.
Install Claude CLI on macOS
On macOS, the cleanest setup is Homebrew plus nvm. Install Node.js first if you haven’t already:
brew install nvm
mkdir ~/.nvm
nvm install --lts
Make sure nvm’s init lines are in your ~/.zshrc, open a new terminal, and confirm node --version reports 18 or higher. Then install the CLI globally:
npm install -g @anthropic-ai/claude-code
Verify the installation by printing the version:
claude --version
Because nvm installs Node in your home directory, you should not need sudo for the global install. If you find yourself reaching for sudo, that’s a sign your Node setup came from the macOS installer package — see the EACCES section below before proceeding.
Install Claude CLI on Linux
On Ubuntu, Debian, Fedora, and most other distributions, the process is nearly identical to macOS. Avoid installing Node through apt or dnf directly, since distro repositories often ship outdated versions below Node 18.
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash
source ~/.bashrc
nvm install --lts
node --version
With Node 18+ active, install the package globally and verify:
npm install -g @anthropic-ai/claude-code
claude --version
On headless servers, note that the browser-based claude login flow is awkward — use the API key method described in the authentication section instead. Everything else works the same over SSH.
Install Claude CLI on Windows
Windows users have two solid options. WSL (Windows Subsystem for Linux) gives you a genuine Linux environment and is what most developers prefer; a native PowerShell install also works for many setups.
Option A: Windows via WSL (recommended)
From an elevated PowerShell window, install WSL with Ubuntu if you haven’t already, then open the Ubuntu shell:
wsl --install
wsl
Inside WSL, follow the Linux instructions exactly: install nvm, install Node 18+, then run npm install -g @anthropic-ai/claude-code. Your Windows files are reachable under /mnt/c/, so you can run Claude against projects that live on your Windows drive.
One practical tip: performance is noticeably better when your project lives inside the Linux filesystem (~/projects) rather than on /mnt/c. Cross-filesystem file watching is slow, and Claude Code does a lot of file scanning.
Option B: Native Windows with PowerShell
Install Node.js 18+ using nvm-windows or the official installer from nodejs.org. Then open PowerShell and install the CLI:
npm install -g @anthropic-ai/claude-code
claude --version
The native Windows experience has improved substantially, but a few edge cases remain — some shell-tooling features assume a POSIX environment. If you hit odd behavior, Git Bash or WSL usually resolves it.
Authenticate Claude CLI
There are two authentication paths. The interactive login is easiest for individuals; the API key is better for servers, containers, and CI pipelines.
Interactive login with claude login
claude login
This opens your browser to an Anthropic sign-in page. Approve the connection, and the CLI stores an OAuth token locally — no keys to manage. If you pay for Claude Pro or Max, this is the option that uses your subscription.
API key via environment variable
Generate a key in the Anthropic Console, then export it in your shell. Add the export line to ~/.zshrc or ~/.bashrc so it persists:
export ANTHROPIC_API_KEY="sk-ant-..."
On native Windows PowerShell, set it like this instead:
setx ANTHROPIC_API_KEY "sk-ant-..."
API-key usage is billed per token through the Anthropic API, separate from any Claude subscription. Treat the key like a password: never commit it to a repository.
First run: your first Claude Code session
Navigate to any project directory and simply run:
cd ~/projects/my-app
claude
The CLI indexes your project, shows a trust prompt for the directory, and drops you into an interactive session. Try a simple request first, like asking it to explain the project structure, before delegating edits.
Two slash commands are worth learning on day one: /help lists available commands, and /init generates a CLAUDE.md file that gives the agent persistent context about your codebase. Once you’re comfortable with the basics, explore Claude Code skills to extend what the agent can do with reusable, task-specific capabilities.
Updating and uninstalling Claude CLI
Claude Code ships updates frequently — often weekly. Newer versions typically check for updates automatically, but a manual update is one command:
npm update -g @anthropic-ai/claude-code
To remove the tool completely, uninstall the package and optionally delete its config directory:
npm uninstall -g @anthropic-ai/claude-code
rm -rf ~/.claude
On Windows PowerShell, replace the second line with Remove-Item -Recurse -Force $env:USERPROFILE.claude. Be aware that deleting .claude removes your login token and local settings, so you’ll re-authenticate on the next install.
Common installation errors and fixes
Most install problems fall into a handful of well-known categories. Here’s what they look like and how to resolve each one.
EACCES permission errors during npm install
If you see npm ERR! code EACCES, your global npm directory is owned by root — a classic symptom of installing Node from the macOS/Linux installer instead of nvm. Do not fix this with sudo npm install; that creates files your user can’t manage later.
The robust fix is to reinstall Node via nvm (which puts the global directory in your home folder), or redirect npm’s global prefix:
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
“claude: command not found” after installing
This is almost always a PATH problem: npm’s global bin directory isn’t in your shell’s PATH. Find where npm installs global binaries, then confirm it’s on your PATH:
npm config get prefix
echo $PATH
The prefix’s bin subdirectory must appear in the PATH output. If it doesn’t, add it to your shell config file and open a new terminal. On WSL, also make sure you’re running claude inside the Linux shell, not in PowerShell where the Windows npm prefix applies.
WSL-specific issues
The browser-based claude login sometimes fails to open a browser from WSL. When that happens, copy the URL printed in the terminal and paste it into a Windows browser manually — the callback still completes.
If you’re on WSL1 and see strange crashes, upgrade to WSL2 with wsl --set-default-version 2; the compatibility layer in WSL1 trips over some Node features. Slow performance almost always means your project sits on /mnt/c — move it into the Linux filesystem.
Errors after a successful install
Once the CLI is running, the failure modes shift from installation to runtime. Rate limits, expired tokens, and transient server errors can all interrupt a session mid-task.
If you start seeing HTTP 500 responses from the API, don’t reinstall — the problem is server-side or auth-related, not your setup. Our guide to Claude Code API error 500 fixes covers token refresh, retry strategy, and status-page checks in detail.
Quick reference: commands by platform
| Task | macOS / Linux | Windows (PowerShell) |
|---|---|---|
| Install CLI | npm install -g @anthropic-ai/claude-code | npm install -g @anthropic-ai/claude-code |
| Verify install | claude –version | claude –version |
| Log in | claude login | claude login |
| Set API key | export ANTHROPIC_API_KEY=”…” | setx ANTHROPIC_API_KEY “…” |
| Start session | claude | claude |
| Update | npm update -g @anthropic-ai/claude-code | npm update -g @anthropic-ai/claude-code |
| Uninstall | npm uninstall -g @anthropic-ai/claude-code | npm uninstall -g @anthropic-ai/claude-code |
Bottom line
To install Claude CLI you need exactly three things: Node.js 18 or newer, one npm command, and an Anthropic login or API key. Using nvm for Node and WSL2 on Windows eliminates roughly all of the common installation failures before they happen.
With the CLI running, the real leverage comes from learning its workflow — project context files, slash commands, and skills. Start with /init in your main repository and iterate from there.