Installation & Setup
Everything you need to install Claude Code on macOS, Windows, or Linux and get authenticated in under five minutes.
Prerequisites
Before you install Claude Code, make sure you have the following:
- A Claude Pro, Max, or Team subscription — Claude Code requires an active Anthropic subscription. The free tier does not include CLI access. You can sign up at claude.ai.
- Node.js 18 or newer — Claude Code is installed via npm, the Node.js package manager. If you do not have Node.js yet, Step 1 below will walk you through it.
- A terminal application — Every operating system ships with one. On macOS, open Terminal (search for it in Spotlight). On Windows, use PowerShell or Windows Terminal. On Linux, open your default terminal emulator.
Installation steps
Install Node.js (if you don't have it)
Open your terminal and check whether Node.js is already installed:
node --version
If you see a version number like v18.17.0 or higher, you are good to go — skip to Step 2.
If the command is not recognized, download and install Node.js from nodejs.org. Choose the LTS (Long Term Support) version — it is the most stable.
After installing, close and reopen your terminal, then run node --version again to confirm it works.
Install Claude Code via npm
With Node.js in place, run this single command to install Claude Code globally on your system:
npm install -g @anthropic-ai/claude-code
The -g flag installs it globally, meaning you can run the claude command from any directory. The download is about 50 MB and should finish in under a minute on most connections.
EACCES error, you may need to prefix the command with sudo:sudo npm install -g @anthropic-ai/claude-codeAlternatively, you can configure npm to install globally without sudo, which is the recommended long-term fix.
Authenticate with your Anthropic account
Now launch Claude Code for the first time:
claude
On first run, Claude Code will open a browser window asking you to log in to your Anthropic account. Sign in with the account that has your Pro, Max, or Team subscription, then authorize the CLI.
Once you approve, the terminal will display a confirmation message and drop you into an interactive prompt. That means you are authenticated and ready to go.
Verify the installation
Run the following command to confirm everything is working:
claude --version
You should see the current version number printed. If you do, congratulations — Claude Code is installed and authenticated.
You can also run claude --help to see a summary of all available flags and options. Do not worry about memorizing them — we will cover the important ones throughout this guide.
Platform-specific notes
macOS
macOS is the most straightforward platform. Use the built-in Terminal app (found in Applications > Utilities) or a third-party terminal like iTerm2. If you use Homebrew, you can install Node.js with brew install node instead of downloading it manually.
Windows
Claude Code works on Windows through WSL 2 (Windows Subsystem for Linux). This gives you a full Linux environment inside Windows. To set it up:
- Open PowerShell as Administrator and run
wsl --install. - Restart your computer when prompted.
- Open the newly installed Ubuntu app from the Start menu, set up a username and password, then follow the Linux instructions below.
Linux
On Ubuntu, Debian, and similar distributions, you may need to install Node.js through NodeSource or use a version manager like nvm, since the default system packages often ship an outdated version. Once Node.js 18+ is installed, the npm install -g command works identically to macOS.
Troubleshooting common issues
“claude: command not found”
This means the global npm bin directory is not on your system PATH. First, find where npm installs global packages:
npm config get prefix
Then add the resulting path (with /bin appended) to your shell profile. For example, on macOS with zsh:
# Add to ~/.zshrc export PATH="$(npm config get prefix)/bin:$PATH"
Then run source ~/.zshrc or open a new terminal window.
Authentication fails or browser does not open
If the browser window does not appear (common on headless servers or WSL), Claude Code will print a URL in the terminal. Copy that URL and paste it into any browser where you are logged in to your Anthropic account. After authorizing, the terminal session will pick up the token automatically.
Node.js version too old
If you see an error about an unsupported Node.js version, upgrade to the latest LTS release. The fastest way is to use nvm:
nvm install --lts nvm use --lts
Updating Claude Code
Claude Code receives frequent updates. To upgrade to the latest version, run:
npm update -g @anthropic-ai/claude-code
You can also check for updates inside Claude Code by running the /update slash command during a session.