Mascot Logo
ai-agents-tutorial

Part 1 · Lesson 3 of 16

How to install Claude Code on macOS, Windows, and Linux

Install Node. Install the CLI. Sign in.

12 min

Step 1 of 5 · Pick your install method

Claude Code ships as a single command-line tool called claude. There are two common ways to get it, and you only need one.

  • Native installer (recommended). A short script downloads a self-contained binary. No Node.js required, and it keeps itself updated in the background.
  • npm. If you already use Node.js, you can install the same binary as a global npm package.

We'll show both below. Pick the one that matches your setup, then continue to the next step.

Step 2 of 5 · Install Claude Code (native installer)

This is the simplest path and works without Node.js. Open your terminal and run the command for your system.

macOS, Linux, or WSL:

curl -fsSL https://claude.ai/install.sh | bash

Windows (PowerShell):

irm https://claude.ai/install.ps1 | iex

Windows (Command Prompt / CMD):

curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd

The installer places the claude binary at ~/.local/bin/claude on macOS/Linux (or %USERPROFILE%\.local\bin\claude.exe on Windows) and adds that folder to your PATH. Native installs update themselves in the background, so you stay on the latest version automatically.

Step 3 of 5 · Or install with npm (optional)

Prefer to manage Claude Code through Node.js? You can install the same tool as a global npm package instead. This path requires Node.js 18 or later.

First confirm Node is available:

node -v

If you see a version like v18.16.0 or v20.9.0, you're set. If you get a "command not found" error, download the LTS build from nodejs.org, run the installer, and restart your terminal.

Then install Claude Code globally:

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

Step 4 of 5 · Start Claude Code and sign in

However you installed it, launch the tool by running:

claude

On first run, Claude Code opens your web browser so you can log in and authorize the CLI. Follow the browser prompts to finish.

Step 5 of 5 · Checkpoint & Recap

Recap

  • Native installer: curl -fsSL https://claude.ai/install.sh | bash (macOS/Linux/WSL) or irm https://claude.ai/install.ps1 | iex (Windows). No Node.js required, auto-updates.
  • npm (optional): npm install -g @anthropic-ai/claude-code — needs Node.js 18+, and never use sudo.
  • claude: Launches the CLI and triggers the first-time sign-in.
  • claude --version: Verifies the CLI is installed and reachable.
  • claude doctor: Runs a deeper health check if something looks off.

Troubleshooting installation

Most install hiccups come down to your shell not finding the claude command yet. Here are the common ones and how to fix them.

"command not found: claude"

If the install finished but your terminal says command not found: claude (macOS/Linux) or 'claude' is not recognized (Windows), the binary installed fine — your shell just doesn't know where to look for it yet. This almost always means the install directory isn't on your PATH. See the next section to fix it.

PATH not updated (~/.local/bin)

The native installer puts claude in ~/.local/bin. If that folder isn't on your PATH, your shell can't run the command. First, check whether it's already there:

echo $PATH | tr ':' '\n' | grep -Fx "$HOME/.local/bin"

If that prints your .local/bin path, you're good. If it prints nothing, add the folder to your shell config. On macOS (Zsh is the default):

echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

On most Linux distributions (Bash is the default):

echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc

Then confirm it worked:

claude --version

On Windows the binary lives at %USERPROFILE%\.local\bin. If claude isn't recognized, add that folder to your User PATH (via PowerShell or System Settings) and restart your terminal.

Diagnose with "claude doctor"

When claude --version works but something still feels off, Claude Code ships a built-in diagnostic. Run it from your shell:

claude doctor

It checks your installation, settings, and configuration in one pass and points you at the specific thing that's wrong. (If you're already inside a Claude Code session, you can run /doctor instead.) This is the first thing to try before searching for an error message.

Frequently asked questions

Do I need Node.js to install Claude Code?

No. The recommended native installer (curl -fsSL https://claude.ai/install.sh | bash on macOS/Linux, irm https://claude.ai/install.ps1 | iex on Windows) downloads a self-contained binary and does not require Node.js. You only need Node.js 18+ if you choose the optional npm install -g @anthropic-ai/claude-code path.

Should I use sudo to install Claude Code?

No. The official docs specifically warn against sudo npm install -g because it can cause permission and security issues. If you hit a permission error with npm, switch to the native installer instead — it installs into your home directory and doesn't need administrator rights.

How do I verify Claude Code installed correctly?

Run claude --version to confirm the CLI is installed and reachable. For a deeper check of your installation and configuration, run claude doctor from your shell (or /doctor from inside a session).

Why does my terminal say "command not found: claude"?

The install succeeded but the install directory (~/.local/bin) isn't on your PATH yet, so your shell can't find the command. Add ~/.local/bin to your PATH in ~/.zshrc (macOS) or ~/.bashrc (Linux), reload it with source, then run claude --version again.