Prerequisites and installation
Install Claude Code in minutes. Prerequisites (Node.js 18+, terminal, Anthropic account), npm installation, API key or Max authentication, and common error troubleshooting.
New to computers?
If words like "terminal," "Node.js," or "API key" sound mysterious, start with our prerequisites for complete beginners page. It explains everything in plain language with concrete analogies.
Prerequisites
Before installing Claude Code, make sure you have these three things. If any of them are missing, don't worry, we explain everything below.
Node.js 18 or higher
Claude Code runs on Node.js, the JavaScript engine that executes code server-side. You need version 18 at minimum (version 22 LTS is recommended).
Download it from nodejs.org or use a version manager like nvm.
A terminal
Claude Code lives in the terminal. On macOS, use Terminal or iTerm2. On Windows, use PowerShell or WSL (Windows Subsystem for Linux). On Linux, any terminal emulator will do.
An Anthropic account
You need either an API key (pay-as-you-go via the Anthropic console) or a Claude Max/Pro/Team subscription that includes Claude Code access.
Create your account at console.anthropic.com.
Check your Node.js version
Open your terminal and type the following command:
Version too old?
If you see a number below v18.0.0, or if the command isn't recognized, you need to install or update Node.js. Check the Troubleshooting section at the bottom of this page.
Installing Claude Code
Installation takes a single command. Open your terminal and run:
This command installs Claude Code globally on your machine. This means the claude command will be available from any folder on your system.
Why the -g flag?
The -g flag means "global." Without it, the package would only be installed in the current folder. With -g, Claude Code becomes a system-wide tool accessible everywhere, like git or node.
Verify the installation
After installation, verify everything works:
If the command is recognized and shows a version number, the installation was successful.
Authentication
On first launch, Claude Code will ask you to authenticate. Two methods are available.
Method 1: API key (pay-as-you-go)
This is the most flexible method. You only pay for what you use.
Generate an API key
Go to console.anthropic.com, sign in, then go to API Keys and click Create Key. Copy the generated key (it starts with sk-ant-).
Set the environment variable
Add your API key to your shell configuration file:
# Add this line to your ~/.bashrc or ~/.zshrcexport ANTHROPIC_API_KEY="sk-ant-your-key-here"# Reload your configurationsource ~/.bashrc # or source ~/.zshrc
Launch Claude Code
Navigate to a project folder and run the claude command. Authentication will be automatic thanks to the environment variable.
API key security
Never share your API key. Never commit it to a Git repository. If you think it's been exposed, regenerate it immediately from console.anthropic.com.
Method 2: Claude Max / Pro / Team subscription
If you have a Claude subscription (Max, Pro, or Team), you can use Claude Code without a separate API key.
Launch Claude Code
Simply run the claude command in your terminal:
claude
Choose the authentication method
Claude Code presents two options. Select Claude App:
? How would you like to authenticate?> Claude App (Max subscription)Anthropic Console (API key)
Sign in through your browser
A browser opens automatically. Sign in with your Claude account. Once authenticated, go back to the terminal, Claude Code is ready.
Which subscription to choose?
The Max subscription ($100/month) provides intensive Claude Code usage. The Pro subscription ($20/month) gives limited access. The API key (pay-as-you-go) is ideal for testing or occasional use, expect around $5-15 per day of active use.
Plan comparison
Essai gratuit
Pour tester Claude Code avant de vous engager. Crédit offert à l'inscription.
- Crédit d'essai à l'inscription
- Accès à Claude via clé API
- Facturation à l'usage après le crédit
- Pas d'abonnement requis
- Idéal pour découvrir l'outil
Claude Max
L'abonnement idéal pour une utilisation régulière de Claude Code. Accès inclus sans clé API séparée.
- Accès illimité à Claude Code
- Pas de clé API à gérer
- Claude.ai web inclus
- Annulation à tout moment
- Idéal pour un usage quotidien
Claude Code API
Pour les développeurs qui préfèrent payer exactement ce qu'ils consomment, sans abonnement fixe.
- Paiement à l'utilisation
- Clé API nécessaire
- Contrôle fin des coûts
- Intégration dans des scripts
- Idéal pour des usages ponctuels
Les prix sont indicatifs et peuvent varier. Consultez anthropic.com/pricing pour les tarifs officiels.
Troubleshooting: common errors
"command not found: node" or version too old
Node.js is not installed or your version is outdated.
# Install nvm (Node.js version manager)curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash# Restart the terminal, then:nvm install 22nvm use 22# Verifynode --version# v22.x.x
"EACCES: permission denied"
npm doesn't have permissions to install global packages.
Never use sudo with npm
The sudo npm install -g command is bad practice that creates cascading permission problems. Use one of the solutions below instead.
Solution 1: Configure the npm prefix (recommended)
mkdir -p ~/.npm-globalnpm config set prefix '~/.npm-global'echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrcsource ~/.bashrc# Re-run the installationnpm install -g @anthropic-ai/claude-code
Solution 2: Use nvm
If you use nvm, permission issues are handled automatically.
"command not found: claude"
The terminal can't find the claude command after installation.
# Check where npm installs global packagesnpm config get prefix# The bin/ subfolder of that path must be in your PATH# If you configured ~/.npm-global:echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrcsource ~/.bashrc
If you closed and reopened your terminal after installation and the problem persists, verify that npm's bin folder is in your PATH variable.
"API key not found" or "Invalid API key"
# Check that the variable is setecho $ANTHROPIC_API_KEY# If nothing shows, the variable isn't configured# Check your shell configuration filecat ~/.bashrc | grep ANTHROPIC# Make sure the key starts with sk-ant-# and hasn't been revoked on console.anthropic.com
Next steps
Claude Code is installed and you're authenticated. Let's configure your environment to get the most out of the tool.
- Configure your environment: API key, settings.json, and CLAUDE.md
- Your first project: Build a website in 5 minutes
- Back to overview: All getting started pages