Claude CodeはAnthropicが提供するAIコーディングアシスタントです。この記事では、Mac・Windows・Linuxの各OSでのインストール方法を詳しく解説します。
インストール前の準備
1. Node.jsのインストール
Claude CodeはNode.js 18以上が必要です。
node --version
v18.0.0 以上が表示されればOKです。
2. Anthropicアカウントの作成
- Claude.aiにアクセス
- 「Sign up」でアカウント作成
- メールアドレスを確認
macOSでのインストール
方法1: npmでインストール(推奨)
brew install node
npm install -g @anthropic-ai/claude-code
claude --version
方法2: Homebrewでインストール
brew update
brew install claude-code
Windowsでのインストール
方法1: ネイティブインストール(推奨)
- Node.js公式サイトからLTS版をダウンロード
- PowerShellを管理者として実行
- インストール:
npm install -g @anthropic-ai/claude-code
方法2: WSL(Windows Subsystem for Linux)
wsl --install
WSL内で:
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
npm install -g @anthropic-ai/claude-code
Linuxでのインストール
Ubuntu/Debian
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -
sudo apt-get install -y nodejs
npm install -g @anthropic-ai/claude-code
Fedora/CentOS
curl -fsSL https://rpm.nodesource.com/setup_20.x | sudo bash -
sudo dnf install -y nodejs
npm install -g @anthropic-ai/claude-code
初期設定
初回起動と認証
claude
初回起動時、ブラウザが自動的に開きAnthropicアカウントでログインします。
日本語設定(オプション)
~/.claude/settings.jsonを作成:
{
"language": "ja"
}
インストール確認
claude --version
claude --help
claude
トラブルシューティング
「command not found」エラー
export PATH="$PATH:$(npm config get prefix)/bin"
source ~/.bashrc
「permission denied」エラー
sudo chown -R $(whoami) $(npm config get prefix)/{lib/node_modules,bin,share}
npm install -g @anthropic-ai/claude-code
Node.jsのバージョンが古い
brew upgrade node # macOS
# または nvm を使用
nvm install 20
nvm use 20
アンインストール方法
npm uninstall -g @anthropic-ai/claude-code
# 設定ファイルも削除
rm -rf ~/.claude
まとめ
OS | 推奨方法 | コマンド |
|---|---|---|
macOS | npm |
|
Windows | npm(管理者) |
|
Linux | npm |
|
インストールのポイント:
- Node.js 18以上が必要
- グローバルインストール(
-gオプション) - 初回起動時に認証が必要
- トラブル時はPATHと権限を確認