0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Windows上でclaudeコマンドを使えるようにするまで ~ WSL2 x AlpineLinux x ClaudeCode ~

Last updated at Posted at 2025-06-05

WSL2 x AlpineLinux x ClaudeCode

ClaudeCodeを使いたいけど、Windows上でClaudeCodeを動かすにはWLS2を使うしかない!
WSL2で簡単にインストールできるUbuntuほど大きいLinuxはいらない!
そんな私が行った WSL2 x AlpineLinux x ClaudeCode の備忘録。

最終的にはWindows上の任意の場所でclaudeコマンドを使えるようにします。
image.png

前提条件

とりあえず、wslコマンドは使える状態から開始します。
image.png

WSL2にAlpineLinuxをインポート

Alpine Linuxのページより、Mini root filesystemをダウンロードします。

一般的にはにはx86_64を選ぶ。
image.png

  1. ダウンロードしたalpine-*******.tar.gzファイルをコマンドプロンプトなどからwslへインポートする。

ファイル名やパスはAlpineLinuxをダウンロードしたパス。

wsl --import ClaudeCode c:\wsl "C:\*****\alpine-*******.tar.gz"

実行結果 例:
image.png

wslへ入る

wsl -d ClaudeCodeを用いることで、AlpineLinuxの環境に入ることができます。
もしくは、Microsoftのターミナルを使っている場合はプロファイルが自動で作成されています。
image.png

AlpineLinuxに入ったら、脳死でパッケージの更新を行う。

apk update
apk upgrade

また、ClaudeCodeに必要なパッケージがAlpineLinux(BusyBox)に不足しているのでインストールします。

apk add coreutils

npmのインストール

ClaudCodeのドキュメントを見ると、ClaudCodeのインストールにはnpmが必要なようです。

image.png

以下のコマンドでnpmをインストールします。

apk add npm

image.png

ClaudCodeのインストール

先ほどのドキュメントを参考にClaudCodeをインストールします。

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

インストールしたらClaudCodeが実行できるか確認します。
claude
image.png
ちゃんと起動できまるので、初期設定とライセンス認証などを行います。(割愛)

claudeコマンドをWindowsから呼び出せるようにする

適当なところに適当なフォルダーを作ります。
image.png
その中に、claude.batファイルを作成し、以下のコマンドを入力します。

wsl -d ClaudeCode --cd "%cd%" claude %*

image.png

システムの環境変数から、パスを作成したディレクトリへ通します。
image.png

任意の場所/プロジェクトでclaudeコマンドが使えるようになりました。

image.png

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?