← Back to WeighMyPrompt

How to Install Claude Code (Mac, Windows, Linux)

Last updated: May 13, 2026 · 5 min read

Claude Code is Anthropic's terminal-based coding agent. Installation is a single npm install on any platform with Node.js 18+, but Windows users should use WSL for full feature support. This guide covers Mac, Windows, and Linux, plus how to update, authenticate, and troubleshoot.

Prerequisites

How to install Claude Code on Mac

1

Install Node 18+ (skip if you already have it)

The easiest path is Homebrew:

brew install node

Or via nvm if you manage multiple Node versions:

nvm install 22
nvm use 22
2

Install Claude Code globally

npm install -g @anthropic-ai/claude-code

If you see a permissions error, use sudo npm install -g @anthropic-ai/claude-code or fix npm's global directory with npm config set prefix ~/.npm-global.

3

Authenticate

claude

First run opens your browser to sign in with your Anthropic account. After login, Claude Code stores a token in ~/.claude and won't prompt again.

4

Launch in any project

cd ~/Projects/my-app
claude

Claude Code starts an interactive session with full access to read, edit, and run commands in the current directory. Exit with Ctrl+D or by typing exit.

How to install Claude Code on Windows

Anthropic officially supports Claude Code via WSL (Windows Subsystem for Linux). Native Windows installs work but lack some features (file watchers, certain MCP servers).

1

Install WSL2 with Ubuntu

Open PowerShell as Administrator:

wsl --install

Restart your machine. Ubuntu opens automatically and asks you to create a Linux user.

2

Install Node 18+ inside WSL

curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs
3

Install Claude Code

sudo npm install -g @anthropic-ai/claude-code

The sudo is needed because npm installs globally into /usr/lib on Ubuntu.

4

Authenticate and launch

claude

WSL automatically opens Windows-side browsers for the OAuth flow. Once authenticated, you can use Claude Code on any folder accessible from WSL — including Windows folders mounted at /mnt/c/Users/YourName/....

If you must run Claude Code natively on Windows (no WSL), use npm install -g @anthropic-ai/claude-code in PowerShell. Expect some features to misbehave — most notably, file-watching during long sessions and a handful of MCP integrations.

How to install Claude Code on Linux

Identical to the Mac flow once Node 18+ is in place. Common Linux installs:

# Ubuntu / Debian
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo -E bash -
sudo apt-get install -y nodejs
sudo npm install -g @anthropic-ai/claude-code

# Fedora / RHEL
sudo dnf install nodejs npm
sudo npm install -g @anthropic-ai/claude-code

# Arch
sudo pacman -S nodejs npm
sudo npm install -g @anthropic-ai/claude-code

# Then authenticate
claude

How to update Claude Code

Re-run the install command with the @latest tag:

npm install -g @anthropic-ai/claude-code@latest

Claude Code also checks for updates on startup and prints a notification when a newer version is available. Check your current version anytime:

claude --version

How to launch Claude Code in your terminal

After install, the claude command is available system-wide. Three common ways to start a session:

Common errors

"command not found: claude"

The npm global bin directory isn't on your PATH. Fix:

npm config get prefix
# Add the output's /bin to your PATH in ~/.zshrc, ~/.bashrc, or equivalent

"EACCES: permission denied" during install

Either use sudo npm install -g ... or fix npm's global directory:

mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.zshrc

"Node version too old"

Claude Code requires Node 18+. Upgrade your Node installation before retrying.

Can I use Claude Code for free?

The CLI itself is free to install, but it requires a paid Anthropic plan (Pro $20/mo, Max $100-200/mo) or API credits to run. New API accounts get $5 in trial credits, which is enough to test Claude Code for 1-2 days of moderate use. See the full Claude Code pricing guide for which plan to pick.

What's next

Estimate cost before you start coding Paste a sample of what you'll ask Claude Code into the WeighMyPrompt calculator to see the token count and cost on Opus, Sonnet, and Haiku. Helps decide between Pro, Max, and API. Open the calculator.

Related