Claude Code tutorial

How to Install Claude Code CLI on Mac and Windows

Learn how to quickly install Anthropic's Claude Code CLI on Mac or Windows using npm. Copyable commands for global installation and terminal authentication.

4 stepsCopyable commandsClaude Code
Interactive tutorial

Quick command sequence

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

/en/tutorials/install-claude-code-cli-mac-windows

Interactive command lab

1/4

Step 1

Check Node.js

Claude Code runs via Node.js v18+. If you don't see version numbers, download Node.js first.

Checkpoint

node -v

zsh — tutorial-lab

Command tray

$ node -v && npm -v

v20.10.0

10.2.3

Step-by-step instructions

  1. 1

    Step

    Check Node.js

    Claude Code runs via Node.js v18+. If you don't see version numbers, download Node.js first.

    node -v && npm -v
  2. 2

    Step

    Install Claude Code Globally

    Using the -g flag ensures claude is added to your system PATH globally.

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

    Step

    Verify Installation

    If you get 'command not found', you may need to restart your terminal or add NPM to your PATH.

    claude --version
  4. 4

    Step

    Authenticate Claude

    A browser window will open asking you to log in to the Anthropic Console. You must have billing enabled.

    claude

Why this matters

Using the official @anthropic-ai/claude-code NPM package ensures you have the genuine Anthropic release with the latest Claude 3.7 capabilities. Unofficial wrappers or outdated packages may lack key security updates or API access features.

Troubleshooting

  • EACCES permission denied: If you get a permissions error on Mac during the global install, use a Node version manager like nvm or prefix your command with sudo (e.g., sudo npm install -g @anthropic-ai/claude-code).
  • Command not found: On Windows, if typing claude returns an error, ensure your NPM global installation path is added to your Environment Variables PATH.
  • Authentication loop or 401 error: If Claude fails to authenticate, force a fresh login by running claude login and verifying you have an active billing setup in the Anthropic Console.

FAQ

What is the npm command for Claude Code?

The official installation command is npm install -g @anthropic-ai/claude-code. The -g flag installs it globally so the claude command works from any directory.

Does Claude Code require Python or Node.js?

Claude Code requires Node.js (version 18 or higher). It does not require Python to run, though it can execute Python code if your projects require it.

Can I run Claude Code on Windows?

Yes, Claude Code is cross-platform. It runs on Windows, Mac, and Linux as long as a compatible version of Node.js is installed.

How to authenticate Claude Code in terminal?

After installing, simply run the command claude. It will prompt you to press Enter, which opens your default web browser to the Anthropic Console for secure OAuth authentication.

Is Claude Code free to use?

While the CLI tool itself is free to download, it uses the Anthropic API (Claude 3.7 Sonnet) to function. You must have an Anthropic Console account with billing enabled to pay for the tokens used.

Related tutorials