Claude Code Installation Guide

1. System Requirements

ItemDetails
OSmacOS 10.15 or later / Ubuntu 20.04+ / Debian 10+ / Windows (WSL required)
HardwareMemory: 4GB or more
SoftwareNode.js 18 or higher
NetworkInternet connection required
ShellBash / Zsh / Fish recommended

2. For Windows Users (Installing WSL/Ubuntu)

  1. Install WSL (Windows Subsystem for Linux) and Ubuntu distribution: wsl --install After rebooting, check available distributions as needed: wsl -l -o
  2. If older versions of node/npm are present in the initial state, remove them: sudo apt remove nodejs npm

3. Installing Node.js (Recommended: nvm)

  1. Install nvm (Node Version Manager): curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash
  2. source ~/.bashrc
  3. Install and use the Node.js LTS version: nvm install --lts
  4. nvm use --lts

4. Installing Claude Code

To install globally (recommended method):

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

Note: It is not recommended to use sudo with the install command.
If you encounter permission errors, please refer to the “Configuration Guide” in the official documentation.

After installation, verify the version:

claude --version

5. Starting and Authenticating Claude Code (OAuth)

  1. Move to your project directory: cd <your-project-directory>
  2. Start Claude Code: claude
  3. On first launch, a selection screen for authentication method will appear.
    Select “2. Anthropic Console account”.
  4. Log into Console via the displayed link or screen in your browser to obtain an authentication code.
  5. Paste the authentication code into the terminal to complete registration.
    The settings will be saved and auto-authentication will occur from the next startup.

6. Manually Setting the API Key for CLI

Specifying via Environment Variable

export ANTHROPIC_API_KEY="sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
claude

Persistent Configuration with settings.json

  1. If the .claude folder does not exist in your home directory, create it: mkdir -p ~/.claude
  2. Create or edit ~/.claude/settings.json as follows: { "env": { "ANTHROPIC_API_KEY": "sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" } }
  • After setting this, the claude command will automatically read your API Key.

7. Checking Configuration & Troubleshooting

  • To check installation and authentication status: claude doctor
  • If you encounter permission issues or npm permission errors, please refer to the “Troubleshooting” section in the official documentation.

8. Bedrock Integration Setup

Add the same three lines to your shell startup file.
vi ~/.bashrc
Then append:
export CLAUDE_CODE_USE_BEDROCK="1"

export AWS_REGION="ap-northeast-1"

export AWS_BEARER_TOKEN_BEDROCK=""


Reload:
source ~/.bashrc

use sonnet as model:
/model sonnet

9. How to Update

Automatic Updates (Enabled by Default)

Claude Code updates itself automatically.

To disable automatic updates:

claude config set autoUpdates false --global
# Or
export DISABLE_AUTOUPDATER=1

Manual Update

claude update

10. Frequently Asked Questions & Notes

  • Most errors during installation or startup are related to permission, Node.js version, or network settings.
  • Windows users must always operate in a WSL + Linux environment.
  • For the latest information, FAQ, and support, please consult the official documentation and the official Discord, etc.

留下评论

通过 WordPress.com 设计一个这样的站点
从这里开始