🍣

Claude CodeをWSLで使うときの注意点

に公開

今回は、こちらの記事を読みClaude Code Actionを試したいと思いました。
https://qiita.com/kyuko/items/ad894bac5ba516683387

Claude Code Actionは、WSLで使うことと前回学びました。
https://zenn.dev/masaru21/articles/b3d6cb8c230cf6

先日WSLが消えた事件があり復旧したままでNPMなどインストールしたか、記憶がありませんでした。
それで、NPMのバージョンを確認したら出てきたので、Claude Code Actionをインストールしようとしました。

まずClaude Codeのインストールが必要です。
でも、

npm install -g @anthropic-ai/claude-code
npm error code 1
npm error path C:\Users\****\AppData\Roaming\npm\node_modules\@anthropic-ai\claude-code
npm error command failed
npm error command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/preinstall.js
npm error Error: Claude Code is not supported on Windows.
npm error Claude Code requires macOS or Linux to run properly.
npm error If you are using WSL (Windows Subsystem for Linux):
npm error   1. Make sure you are running npm install from within the WSL terminal, not from PowerShell or CMD
npm error   2. If you're still seeing this message in WSL, your environment may be incorrectly reporting as Windows
npm error Please visit https://docs.anthropic.com/en/docs/agents-and-tools/claude-code/overview#check-system-requirements for troubleshooting information.
npm error A complete log of this run can be found in: C:\Users\***\AppData\Local\npm-cache\_logs\2025-05-26T08_52_06_237Z-debug-0.log

とエラーが出てしまいました。
どうやら私が、WindowsのターミナルからWSLのUbuntuを起動したため、WindowsのパスのNPMなどを使おうとしてエラーが出たようです。

それで、こちらのコマンドで、インストールしました。

curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash -
sudo apt install -y nodejs

バージョンを確認しました。

node -v
npm -v

ターミナルを閉じて、スタートメニューからWSLのUbuntuを起動しました。
そして、

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

で、インストールしました。

npm notice
npm notice New major version of npm available! 10.8.2 -> 11.4.1
npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.4.1
npm notice To update run: npm install -g npm@11.4.1
npm notice

とインストールできました。

sudo npm install -g npm@11.4.1
npm error code EBADENGINE
npm error engine Unsupported engine
npm error engine Not compatible with your version of node/npm: npm@11.4.1
npm error notsup Not compatible with your version of node/npm: npm@11.4.1
npm error notsup Required: {"node":"^20.17.0 || >=22.9.0"}
npm error notsup Actual:   {"npm":"10.8.2","node":"v18.20.8"}
npm error A complete log of this run can be found in: /root/.npm/_logs/2025-05-26T09_53_51_237Z-debug-0.log

Node.js をバージョン 20 以上にアップグレード必要な状況でした。
この手順で、アップデートしました。

# 古いNode.jsの設定を解除(念のため)
sudo apt remove nodejs -y

# Node.js 20.x のセットアップスクリプトを取得
curl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash -

# Node.js 20.x をインストール
sudo apt install -y nodejs

バージョンを確認しました。

node -v
v20.19.2
npm -v
10.8.2

npm を最新版(11.4.1)に更新しました。

sudo npm install -g npm@11.4.1

このようになりました。

sudo npm install -g npm@11.4.1

removed 9 packages, and changed 106 packages in 10s

25 packages are looking for funding
  run `npm fund` for details

これで、ようやくClaud Codeのインストールができます。

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

added 5 packages, and changed 3 packages in 2s

7 packages are looking for funding
  run `npm fund` for details
'''
インストールできました。
```bash
 claude --help
Usage: claude [options] [command] [prompt]

Claude Code - starts an interactive session by default, use -p/--print for non-interactive output

Arguments:
  prompt                          Your prompt

Options:
  -d, --debug                     Enable debug mode
  --verbose                       Override verbose mode setting from config
  -p, --print                     Print response and exit (useful for pipes)
  --output-format <format>        Output format (only works with --print): "text" (default), "json" (single result), or
                                  "stream-json" (realtime streaming) (choices: "text", "json", "stream-json")
  --mcp-debug                     [DEPRECATED. Use --debug instead] Enable MCP debug mode (shows MCP server errors)
  --dangerously-skip-permissions  Bypass all permission checks. Only works in Docker containers with no internet
                                  access.
  --allowedTools <tools...>       Comma or space-separated list of tool names to allow (e.g. "Bash(git:*) Edit Write")
  --disallowedTools <tools...>    Comma or space-separated list of tool names to deny (e.g. "Bash(git:*) Edit Write")
  --mcp-config <file or string>   Load MCP servers from a JSON file or string
  -c, --continue                  Continue the most recent conversation
  -r, --resume [sessionId]        Resume a conversation - provide a session ID or interactively select a conversation
                                  to resume
  --model <model>                 Model for the current session. Provide an alias for the latest model (e.g. 'sonnet'
                                  or 'opus') or a model's full name (e.g. 'claude-sonnet-4-20250514').
  -v, --version                   Output the version number
  -h, --help                      Display help for command

Commands:
  config                          Manage configuration (eg. claude config set -g theme dark)
  mcp                             Configure and manage MCP servers
  migrate-installer               Migrate from global npm installation to local installation
  doctor                          Check the health of your Claude Code auto-updater
  update                          Check for updates and install if available

私は、このあとDNSの問題が出ました。

# Google DNS を使用
sudo nano /etc/resolv.conf
# この内容に、書き換えます。
nameserver 8.8.8.8
nameserver 1.1.1.1

この後ログインのコマンドを試しました。

claude auth login

私は、これで使るようになりました。
でも、まだクレジットの追加をしていないので、今回は、ここまでです。

PROプランでもClaude Codeを使えるようになったので

もう一度Claudeを起動してみました。
確認画面のあと、この画面が表示されました。

/int を実行しました

https://console.anthropic.com/settings/billing

をクリックしました。
PROのサブスクリプションを契約していなかったので、ここまでです。


ログアウトしたら、使用量が表示されることを知りました。

Claude PROを契約しました。

既にClaude Codeのインストールはできていたので、認証を行い利用できました。
API料金のはずなので、いくらになるかドキドキしていました。
でもAPIの使用量に反映されないので、Claude Codeの料金をGensparkで調べてみました。

このような回答でした。

Claude Codeの利用について
重要なポイント:Claude PROサブスクリプションにClaude Codeが含まれています!

2025年6月の最新情報によると、Claude Codeは現在Claude PROプラン($20/月)に含まれています。これは大きな変更で、以前は別途API料金が必要でしたが、現在は統合サブスクリプションとなっています。Anthropic公式サポート

Claude Codeの使用制限
Proプラン: 5時間ごとに約10-40回のClaude Codeプロンプトが可能
使用制限: Claude Webアプリとターミナルでのコード利用で共通の使用制限
モデル: PROプランではSonnet 4にアクセス可能(Opus 4は利用不可)
制限を超えた場合の選択肢
使用制限に達した場合、以下の選択肢があります:

待機: 5時間後に制限がリセット
プラン変更: Maxプラン($200/月)にアップグレード
API課金: 別途API料金で継続利用(オプション)
まとめ
Claude PROサブスクリプション(月額$20)で、Claude Codeを追加料金なしでターミナルから直接利用できます。これは非常にお得な変更で、以前は別途高額なAPI料金が必要でしたが、現在は統合されたプランで利用可能です。

ただし、使用制限があるため、集中的にコーディング作業を行う場合は制限に注意が必要です。大量利用が予想される場合は、Maxプラン($200/月)への変更も検討できます。

この調査結果を見て、安心しました。
Claude PROの料金にClaude Codeの料金が含まれていて、10から40回の利用ができるというのは、とても安心できました。
いつもウェブで利用していたのですが、ファイルの修正がとても大変だったのです。
ウェブの利用でも2時間利用制限を受けることが、今日一日で3回程度ありました。
本格的なプログラムというかシステムを作っているのですが、とても助かっています。
お陰様で、Google Workspace関連のツール、プログラム開発が捗っています。
OpenAIのモデルでは、UIのデザインなどClaude sonnet4の方が優れているように思えるので、今回頑張ってClaude PROの利用を始めました。

リミット表示

claude Codeのリミットが近づいてきた表示も、確認できました。

Discussion