Installation Beginner

Get Claude Code installed and running in just a few minutes. This guide walks you through prerequisites, installation, authentication, and your first run on macOS, Linux, and Windows.

Prerequisites

Before installing Claude Code, make sure you have the following:

Requirement Minimum Version How to Check
Node.js 18.0 or later node --version
npm Comes with Node.js npm --version
Git 2.x (recommended) git --version
Operating System macOS, Linux, or Windows (WSL)
Don't have Node.js? Download it from nodejs.org. Choose the LTS (Long Term Support) version. On macOS, you can also install via Homebrew: brew install node.

Verify Prerequisites

Terminal
# Check Node.js version (must be 18+)
$ node --version
v20.11.0

# Check npm version
$ npm --version
10.2.4

# Check git version (recommended but not strictly required)
$ git --version
git version 2.43.0

Install Claude Code

Claude Code is distributed as an npm package. Install it globally so you can use the claude command from anywhere.

  1. Install globally via npm
    Terminal
    $ npm install -g @anthropic-ai/claude-code
    Permission Error? If you see an EACCES permission error on macOS/Linux, either fix your npm permissions (recommended) or use sudo npm install -g @anthropic-ai/claude-code.
  2. Verify the installation
    Terminal
    $ claude --version
    claude-code/1.x.x

    If you see a version number, Claude Code is installed correctly.

Platform-Specific Instructions

macOS

Terminal (macOS)
# Option 1: Install Node.js via Homebrew (recommended)
$ brew install node

# Option 2: Install Node.js via the official installer
# Download from https://nodejs.org

# Then install Claude Code
$ npm install -g @anthropic-ai/claude-code

Linux (Ubuntu/Debian)

Terminal (Linux)
# Install Node.js via NodeSource (recommended for latest versions)
$ curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
$ sudo apt-get install -y nodejs

# Or use nvm (Node Version Manager)
$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
$ nvm install 20
$ nvm use 20

# Install Claude Code
$ npm install -g @anthropic-ai/claude-code

Windows (via WSL)

PowerShell (as Administrator)
# Step 1: Install WSL if not already installed
PS> wsl --install

# Step 2: Restart your computer, then open Ubuntu from Start Menu
Terminal (Inside WSL/Ubuntu)
# Install Node.js inside WSL
$ curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
$ sudo apt-get install -y nodejs

# Install Claude Code
$ npm install -g @anthropic-ai/claude-code

# Navigate to your Windows project (accessible via /mnt/c/)
$ cd /mnt/c/Users/YourName/projects/my-app
$ claude
Important for Windows Users: Claude Code must be run inside WSL, not in PowerShell or Command Prompt directly. Your Windows files are accessible inside WSL at /mnt/c/.

Authentication

Claude Code needs an API key to communicate with Claude. You have two options for authentication:

Option 1: Interactive Login (Recommended)

When you run claude for the first time, it will guide you through the login process.

Terminal
$ claude

# Claude Code will open your browser for authentication
# Log in with your Anthropic account
# Your credentials are saved locally for future sessions

Option 2: API Key via Environment Variable

Set the ANTHROPIC_API_KEY environment variable directly:

Terminal
# Set the API key for the current session
$ export ANTHROPIC_API_KEY="sk-ant-api03-your-key-here"

# Or add it to your shell profile for persistence
$ echo 'export ANTHROPIC_API_KEY="sk-ant-api03-your-key-here"' >> ~/.bashrc
$ source ~/.bashrc
Keep Your API Key Secret: Never commit your API key to git or share it publicly. Use environment variables or a secrets manager. If your key is compromised, rotate it immediately at console.anthropic.com.

First Run Walkthrough

Once installed and authenticated, here is what your first Claude Code session looks like:

  1. Navigate to a project directory
    Terminal
    $ cd ~/projects/my-web-app
  2. Start Claude Code
    Terminal
    $ claude

    Claude Code will display a welcome message and a prompt where you can type your requests.

  3. Ask your first question
    Claude Code
    Claude > What does this project do? Give me a high-level overview.

    Claude will read your project files and give you a summary of the codebase structure, technologies used, and main functionality.

  4. Try a simple edit
    Claude Code
    Claude > Add a comment at the top of README.md with today's date

    Claude will show you the proposed edit and ask for your approval before making the change.

Troubleshooting Common Issues

This means the npm global bin directory is not in your PATH. Fix it by running:

Terminal
# Find where npm installs global packages
$ npm config get prefix

# Add the bin directory to your PATH
$ echo 'export PATH="$(npm config get prefix)/bin:$PATH"' >> ~/.bashrc
$ source ~/.bashrc

Fix npm permissions instead of using sudo. The recommended approach is to change npm's default directory:

Terminal
$ mkdir ~/.npm-global
$ npm config set prefix '~/.npm-global'
$ echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
$ source ~/.bashrc
$ npm install -g @anthropic-ai/claude-code

Claude Code requires Node.js 18 or later. Upgrade using nvm (Node Version Manager):

Terminal
$ nvm install 20
$ nvm use 20
$ node --version  # Should show v20.x.x
$ npm install -g @anthropic-ai/claude-code

If you see authentication errors:

  • Verify your API key is correct at console.anthropic.com
  • Make sure the ANTHROPIC_API_KEY environment variable is set: echo $ANTHROPIC_API_KEY
  • Check that your API key has not been revoked or expired
  • Ensure you have sufficient credits in your Anthropic account

If you are behind a corporate proxy or firewall:

Terminal
# Set proxy for npm
$ npm config set proxy http://proxy.company.com:8080
$ npm config set https-proxy http://proxy.company.com:8080

# Set proxy for Claude Code API calls
$ export HTTPS_PROXY="http://proxy.company.com:8080"

Updating Claude Code

Keep Claude Code up to date to get the latest features and bug fixes:

Terminal
# Update to the latest version
$ npm update -g @anthropic-ai/claude-code

# Check the installed version
$ claude --version

Uninstalling

Terminal
# Remove Claude Code
$ npm uninstall -g @anthropic-ai/claude-code

# Optionally remove configuration files
$ rm -rf ~/.claude

Try It Yourself

Install Claude Code on your system and run claude --version to verify it works. Then navigate to any project directory and start a session with claude. Ask it to describe the project to you.