Windows環境でClaude Codeを最新版に更新したいけど、うまくいかない…そんな悩みを抱えていませんか?本記事では、Windows特有の注意点を踏まえた更新方法を詳しく解説します。
Windows環境での基本的な更新方法
PowerShellでの更新
# 管理者権限でPowerShellを開く
# 現在のバージョン確認
claude --version
# 最新版に更新
npm update -g @anthropic-ai/claude-code
# または明示的に最新版をインストール
npm install -g @anthropic-ai/claude-code@latest
# 更新後のバージョン確認
claude --version
コマンドプロンプトでの更新
# 管理者として実行を推奨
npm update -g @anthropic-ai/claude-code
# バージョン確認
claude --version
WSL環境での更新
WSL2 (Ubuntu) での更新
# WSLターミナルで実行
sudo npm update -g @anthropic-ai/claude-code
# または
npm install -g @anthropic-ai/claude-code@latest
# バージョン確認
claude --version
WSLとWindowsネイティブの切り替え
# WSL内のClaude Code
which claude
# 出力例: /usr/local/bin/claude
# Windowsネイティブ(PowerShellから)
where claude
# 出力例: C:\Users\username\AppData\Roaming\npm\claude.cmd
Git Bashでの更新
# Git Bashを管理者として実行
npm update -g @anthropic-ai/claude-code
# パスの確認
which claude
# バージョン確認
claude --version
Windows特有の注意点
1. 管理者権限の問題
# エラー例
# npm ERR! Error: EPERM: operation not permitted
# 解決策:管理者権限でターミナルを開く
# 1. スタートメニューで「PowerShell」を検索
# 2. 右クリック → 「管理者として実行」
# 3. 更新コマンドを実行
npm install -g @anthropic-ai/claude-code@latest
2. パスの問題
# npmのグローバルパスを確認
npm config get prefix
# 環境変数PATHに含まれているか確認
$env:PATH -split ';' | Select-String 'npm'
# パスが通っていない場合は追加
# システム環境変数に以下を追加:
# %USERPROFILE%\AppData\Roaming\npm
3. ファイルロックの問題
# 更新前にClaude Codeのプロセスを終了
Get-Process | Where-Object {$_.ProcessName -like "*claude*"} | Stop-Process -Force
# その後更新
npm install -g @anthropic-ai/claude-code@latest
Windows環境別の更新手順
Windows 11 ネイティブ
# 1. Windows Terminalを管理者として開く
# 2. 更新実行
npm install -g @anthropic-ai/claude-code@latest
# 3. 新しいターミナルウィンドウで確認
claude --version
Windows 10 ネイティブ
# 1. PowerShellを管理者として開く
# 2. 実行ポリシーを確認
Get-ExecutionPolicy
# 3. 必要に応じて変更
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
# 4. 更新実行
npm install -g @anthropic-ai/claude-code@latest
WSL2 + Windows Terminal
# WSLタブで実行
npm install -g @anthropic-ai/claude-code@latest
# Windowsとは別環境なので個別に更新が必要
トラブルシューティング
更新が反映されない
# 1. ターミナルを完全に閉じて再起動
# 2. キャッシュをクリア
npm cache clean --force
# 3. 再インストール
npm uninstall -g @anthropic-ai/claude-code
npm install -g @anthropic-ai/claude-code@latest
# 4. 新しいターミナルで確認
claude --version
npmコマンドが見つからない
# Node.jsがインストールされているか確認
node --version
npm --version
# インストールされていない場合
# https://nodejs.org/ からインストール
# または winget を使用
winget install OpenJS.NodeJS.LTS
アクセス拒否エラー
# npmディレクトリの権限を修正
# %USERPROFILE%\AppData\Roaming\npm に対して
# 現在のユーザーにフルコントロール権限を付与
# または別のディレクトリにインストール
npm config set prefix "C:\npm-global"
# 環境変数PATHに C:\npm-global を追加
自動更新スクリプト(Windows用)
PowerShellスクリプト
update-claude-code.ps1:
# Claude Code更新スクリプト(Windows用)
$ErrorActionPreference = "Stop"
Write-Host "現在のバージョンを確認中..." -ForegroundColor Cyan
$current = claude --version 2>$null
Write-Host "最新バージョンを確認中..." -ForegroundColor Cyan
$latest = npm view @anthropic-ai/claude-code version 2>$null
Write-Host "現在: $current"
Write-Host "最新: $latest"
if ($current -ne $latest) {
Write-Host "`n更新を実行します..." -ForegroundColor Yellow
npm install -g @anthropic-ai/claude-code@latest
Write-Host "更新完了!" -ForegroundColor Green
} else {
Write-Host "`n既に最新版です。" -ForegroundColor Green
}
タスクスケジューラでの自動実行
- タスクスケジューラを開く
- 基本タスクの作成
- トリガー:毎週
- 操作:プログラムの開始
- プログラム:
powershell.exe - 引数:
-ExecutionPolicy Bypass -File "C:\Scripts\update-claude-code.ps1"
VS Codeとの連携
VS Code内での更新
# VS Codeの統合ターミナルで実行
npm install -g @anthropic-ai/claude-code@latest
# VS Codeを再起動して反映
拡張機能の更新確認
- VS Codeを開く
- 拡張機能パネル(Ctrl+Shift+X)
- Claude Code拡張機能を検索
- 更新があれば「更新」ボタンをクリック
まとめ
Windows環境でのClaude Code更新ポイント:
- 管理者権限:PowerShell/CMDを管理者として実行
- WSL環境:WindowsネイティブとWSLは別々に更新
- パス設定:npmグローバルパスが環境変数に含まれているか確認
- プロセス終了:更新前にClaude Codeを終了
- ターミナル再起動:更新後は新しいターミナルで確認
Windows特有の問題を理解しておけば、スムーズにClaude Codeを最新状態に保てます。