Guides

How to Install the Claude Code CLI on Mac and Windows

7 min read#claude-code#cli#installation#mac#windows

Who this is forFor readers who stalled on old guides saying to install Node.js first and need the right install path for their Mac or Windows PC.

TL;DR: To use Claude Code directly in the terminal, you need to install the CLI. The recommended path is one line from the official install script, and Node.js is not required. Mac and Windows open different windows and use different commands, so this article covers each in its own track.

Contents

  1. Why this article exists
  2. If you are new to the terminal
  3. Step 1. Run the install script in one line
  4. Other install methods
  5. The npm path is optional
  6. Step 2. Run claude and log in
  7. If something goes wrong

Why this article exists

Claude Code isn’t a desktop app; you use it directly in the terminal. But many guides you find in search still describe the old approach of “install Node.js first.” The CLI itself is one tool, but the window you open and the command you run during installation differ between Mac and Windows. So this article lays out one currently recommended path, side by side for each operating system.

You only need to know whether your computer is a Mac or a Windows PC. Follow along from there.

If you are new to the terminal

You don’t need to have opened a terminal before. Here’s how to open one, as described in the official docs.

Mac: Press Cmd + Space to open Spotlight search, type “Terminal,” and press Enter.

Windows: Press Win + X and pick “Windows PowerShell” from the menu. Searching “PowerShell” in the Start menu opens the same window.

Either way, a window with only a blinking cursor opens. That window is the terminal. There’s nothing to click with the mouse. All you need to do is paste the code block below and press Enter.

Step 1. Run the install script in one line

There are several ways to install Claude Code, but the one the official docs mark as Recommended is the install script below. This path doesn’t use Node.js at all.

Mac (Linux and WSL work the same way)

  1. Window to open Terminal Open Spotlight with Cmd + Space and type "Terminal"
  2. Install command Paste the code block below Paste into Terminal and press Enter
  3. Check command claude --version If a version string prints, it worked

Done with this one line; no Node.js needed

Windows (PowerShell)

  1. Window to open PowerShell Type "PowerShell" in the Start menu
  2. Install command Paste the code block below Paste into PowerShell and press Enter
  3. Check command claude --version If a version string prints, it worked

Done with this one line; no Node.js needed

On both Mac and Windows, you open a window, paste one line of install script, and finish with a check command. The actual command to paste is in the code block below

On Mac, Linux, and WSL, paste the command below into the terminal.

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

On Windows, paste the command below into PowerShell.

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

Other install methods

The same docs list other paths too. If you already use one of the tools below, you can use it as is.

Method Command Notes
Mac Homebrew brew install --cask claude-code If you already have Homebrew
Windows winget winget install Anthropic.ClaudeCode If you already have winget
npm npm install -g @anthropic-ai/claude-code Requires Node.js. See the section below

The npm path is optional

If you used the Step 1 install script, you don’t need this section. Claude Code can also be installed through npm, but that’s an option for people who already use npm, not the recommended path.

Only refer to the notes below if you want to install Claude Code through npm for another project. The official docs say the npm path requires Node.js 22 or later, and they explicitly say not to use sudo npm install -g. The page’s default selections in the screenshots (nvm on Mac, Chocolatey on Windows) are developer paths that start by installing a version manager. Instead of following those, it’s simpler to download the installer under “Or get a prebuilt Node.js®”: a .pkg file on Mac, or a .msi file on Windows.

Node.js download page with macOS, nvm, and npm selected. A Bash code block shows the nvm install command, plus nvm install 24 and node -v confirming v24.19.0. Below that are the prebuilt Node.js instructions for macOS, with green buttons for macOS Installer (.pkg) and Standalone Binary (.gz)
The screen for downloading Node.js on Mac. Only needed if you're taking the npm path
Same Node.js download page with the top selector switched to Windows, Chocolatey, and npm. A PowerShell code block shows the Chocolatey install command and choco install nodejs. Below that are the prebuilt Node.js instructions for Windows, with green buttons for Windows Installer (.msi) and Standalone Binary (.zip), and the architecture selector set to ARM64
The screen for downloading Node.js on Windows. The architecture box defaults to ARM64, so check that it matches your computer before downloading. You can find the system type under System, then About, in Windows Settings (the Korean UI labels this differently). The version in the screenshot is v24.19.0 LTS, so the Node.js 22-or-later requirement for the Claude Code npm package is met automatically

Step 2. Run claude and log in

If claude --version printed a version, the install is done. Now type claude and press Enter.

The first time you run it, you need to log in. A browser window opens automatically and takes you to the login screen. If you have a free-plan account, you’ll be blocked at this step (see the pitfall at the top). After you log in and return to the terminal, a welcome screen appears. When you see this screen, you’re ready.

A few things worth knowing once you’re inside:

  • You can’t click with the mouse inside the terminal. Move with the arrow keys.
  • To stop Claude while it’s running something, press Esc.
  • To exit, type exit, or press Ctrl + D twice at an empty prompt.
  • Type /help to see the list of available commands.

If something goes wrong

The cause differs depending on whether the install command itself fails or the install works but login doesn’t. The responses below are organized by symptom, following the official troubleshooting docs.

When the install command fails

Symptom Cause What to do
syntax error near unexpected token '<', or HTML code appears on screen The install address returned a web page instead of the script Run the same command again after a while. If it keeps failing, install with brew install --cask claude-code on Mac or winget install Anthropic.ClaudeCode on Windows
curl: (22) ... 403 A firewall or proxy blocked it, or the region isn’t supported Use the alternative install command above
irm not recognized in PowerShell (is not recognized) The window you opened is Command Prompt, not PowerShell Open PowerShell fresh and retry, or use the Command Prompt-only command curl -fsSL https://claude.ai/install.cmd -o install.cmd && install.cmd && del install.cmd
command not found: claude / 'claude' is not recognized Installed, but the install folder isn’t on PATH yet (the list of folders the shell searches for commands) Close the window, open a new one, and retry. If it still fails, run the PATH command below

If command not found keeps appearing, add the install folder to PATH directly.

Mac (Zsh): Paste the two lines below and run them, then open a new terminal.

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

Windows (PowerShell): Paste the command below and run it, then open a new window.

$currentPath = [Environment]::GetEnvironmentVariable('PATH', 'User')
[Environment]::SetEnvironmentVariable('PATH', "$currentPath;$env:USERPROFILE\.local\bin", 'User')

If you get an error saying the install folder isn’t writable, then on Mac or Linux, reset the owner to your account with the command below. On Windows, the install location is inside your user folder (%USERPROFILE%), so this error almost never happens.

sudo mkdir -p ~/.local/bin
sudo chown -R $(whoami) ~/.local

When the install works but login doesn’t

Symptom Cause What to do
The browser doesn’t open automatically Automatic launch may not work depending on the environment On the login waiting screen in Claude Code, press c to copy the login address, then paste it into your browser manually
OAuth error: Invalid code The login code expired, or part of it was cut off while copying Press Enter to retry. If the browser opens, finish logging in quickly
403 Forbidden after login The account is on the free plan, or the subscription is inactive Check your subscription status at claude.ai/settings
You don’t know the cause - Log out with /logout, quit the terminal, then restart with claude and log in again

If your symptom isn’t in the tables above, run claude doctor and check the diagnostic results. It will tell you what’s missing.

The install commands and account requirements in this article were checked on August 24, 2026, at code.claude.com/docs/en/setup. The terminal-opening steps and first-run guidance were checked the same day at code.claude.com/docs/en/terminal-guide, and the symptom-based responses in “If something goes wrong” were checked at code.claude.com/docs/en/troubleshoot-install. The Node.js page and version numbers (v24.19.0, npm 11.17.0) were checked on the same day at nodejs.org/en/download. Install methods and account requirements may change, so if your screen looks different, follow the official docs.

Frequently asked questions

Do I need Node.js to install Claude Code?
No. The recommended install script is a single line from the official docs and does not use Node.js. Node.js is only needed for the optional npm install path, which requires Node.js 22 or later.
Can I use Claude Code on the free Claude.ai plan?
No. Claude Code requires a Pro, Max, Team, Enterprise, or Console account. The install finishes on the free plan, but login is blocked.