Skip to main content
Chapter 1 Getting Started with Claude Code

Installing Claude Code and Its Dependencies

11 min read Lesson 2 / 37 Preview

Installing Claude Code and Its Dependencies

This lesson walks you through installing Claude Code and everything you need to start coding with AI from your terminal.

Step 1: Install Node.js

Claude Code requires Node.js 18 or later. Check your current version:

node --version

If you need to install or update Node.js:

  • macOS: brew install node or download from nodejs.org
  • Windows: Download the installer from nodejs.org or use winget install OpenJS.NodeJS
  • Linux: Use your package manager or nvm for version management
# Using nvm (recommended for version management)
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.0/install.sh | bash
nvm install 22
nvm use 22

Step 2: Install Claude Code

Install Claude Code globally using npm:

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

Verify the installation:

claude --version

Step 3: Configure Your API Key

Claude Code needs an Anthropic API key. Get yours from the Anthropic Console (console.anthropic.com):

# Set your API key
export ANTHROPIC_API_KEY="sk-ant-your-key-here"

# Add to your shell profile for persistence
echo 'export ANTHROPIC_API_KEY="sk-ant-your-key-here"' >> ~/.zshrc

Step 4: Your First Claude Code Session

Navigate to any project directory and start Claude Code:

mkdir radio-pulse && cd radio-pulse
claude

You are now in an interactive session. Try your first command:

> What files are in this directory?

Claude Code will execute ls (or equivalent) and report back. You are now coding with AI.

Step 5: Key Configuration Options

Claude Code has several useful configuration options:

# Set your preferred model
claude config set model claude-sonnet-4-6

# Enable verbose mode for debugging
claude config set verbose true

# Check your current configuration
claude config list

Understanding the Permission System

Claude Code asks for permission before executing potentially impactful commands. You will see prompts like:

Claude wants to execute: npm install express
Allow? (y/n/always)
  • y — Allow this specific command
  • n — Deny this command
  • always — Allow this type of command for the rest of the session

Pro tip: In the early lessons, approve commands individually so you understand what Claude Code is doing. As you gain confidence, use "always" for routine operations.

Troubleshooting Common Issues

Issue Solution
claude: command not found Ensure npm global bin is in your PATH
API key errors Verify your key at console.anthropic.com
Permission denied Run chmod +x $(which claude)
Slow responses Check your internet connection and API quota

Key Takeaways

  • Claude Code requires Node.js 18+ and an Anthropic API key
  • Install globally with npm install -g @anthropic-ai/claude-code
  • Start a session by running claude in any project directory
  • The permission system keeps you in control of all file and command operations