Skip to main content

Installation Guide

What you'll learn in this chapter: Prerequisites for Claude Code, OS-specific installation steps, and how to verify your installation

Prerequisites

Before starting this chapter, you'll need:

  • An internet connection
  • Basic familiarity with a terminal (Command Prompt / PowerShell / Terminal)

Before You Begin

RequirementVersionHow to check
Node.js18 or higher (LTS recommended)node --version
npmInstalled with Node.jsnpm --version
Anthropic API key--Covered in the next chapter

Installing Node.js (if you don't have it yet)

Official download: nodejs.org -- select the LTS version

Installing Node.js on Windows
  1. Go to nodejs.org
  2. Download the LTS version .msi installer
  3. Run the installer (keep the defaults: Next -> Next -> Install)
  4. Restart PowerShell and verify:
    node --version   # v22.x.x
    npm --version # 10.x.x
Installing Node.js on macOS

Using Homebrew (recommended):

# Install Homebrew first if you don't have it
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# Install Node.js
brew install node

# Verify
node --version
npm --version
Installing Node.js on Linux (Ubuntu/Debian)
# Add the NodeSource repository
curl -fsSL https://deb.nodesource.com/setup_lts.x | sudo -E bash -

# Install
sudo apt-get install -y nodejs

# Verify
node --version
npm --version

Installing Claude Code

Once you're ready, install with a single command:

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

The -g flag installs globally, so you can use the claude command from any directory.

Note for Windows Users

If you encounter a permission error in Windows PowerShell:

# Open PowerShell as Administrator and run
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

Alternatively, consider using Git Bash instead of PowerShell.


Verifying the Installation

claude --version

Expected output (the version number may vary depending on when you install):

1.x.x (Claude Code)

First Run and API Key Prompt

claude

On first launch, you'll be prompted to enter your API key:

Welcome to Claude Code!

Please enter your Anthropic API key to get started.
You can find your API key at https://console.anthropic.com/
API key: sk-ant-...

How to get an API key is covered in detail in the next chapter.


Common Installation Issues

Issue 1: npm: command not found

Node.js is not installed. Follow the Node.js installation steps above first.

Issue 2: EACCES: permission denied (macOS/Linux)

# This is an npm global directory permission issue
# Fix: Change the npm global directory
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

Issue 3: claude command not found after installation

Close your terminal completely and reopen it. This refreshes the PATH environment variable.

Issue 4: Installation fails on a corporate network

You may need to configure a proxy:

npm config set proxy http://your-proxy-address:port
npm config set https-proxy http://your-proxy-address:port
npm install -g @anthropic-ai/claude-code

Key Takeaways

  • Claude Code requires Node.js 18+
  • Install with npm install -g @anthropic-ai/claude-code
  • Verify with claude --version
  • API key setup is covered in the next chapter

Next Step

API Key Setup -- Get your API key from the Anthropic Console and configure it