Step-by-step instructions
- 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
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
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
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
Copilot
How to Install GitHub Copilot CLI on Mac and Windows
Step-by-step guide to installing the GitHub Copilot CLI extension. Learn how to authenticate and run gh copilot suggest and explain in your terminal.
Aider
How to Install Aider AI Coding CLI on Mac and Windows
Step-by-step guide to installing the Aider AI pair programming CLI on macOS and Windows. Learn how to configure API keys for Claude 3.7 and GPT-4o.