1
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?

claude codeが迷子、npm版からネイティブインストールへの移行周り

Last updated at Posted at 2025-08-21

現象

claude codeが迷子になる事象が最近発生していた。
ターミナルで以下実行しても、さっきまで動いていたのにいない?!ってことが度々。

which claude

❯ claude
zsh: command not found: claude

考えられる原因

  • 自分の環境がそこそこ汚れている
    • nvmやnodebrewなどnodeの実行環境が混在(どこかで直したい)
  • 実行環境のせいで一度、claude codeを再インストールした際、どこかでネイティブインストールのコマンドを流してしまったらしい
    • のちに触れるが、シンボリックリンクが2つある状態であり、より迷子になりやすい状態だった

状況確認

インストール前の状態確認

どこで動作しているかを確認

claude doctor

warningが出ているので、修正にかかる。
multiple instalations、シンボリックリンクが2つ。これだとだめそう。

 Diagnostics
 └ Currently running: npm-global (1.0.86)
 └ Path: ~/.nvm/versions/node/v23.11.0/bin/node
 └ Invoked: ~/.nvm/versions/node/v23.11.0/bin/claude
 └ Config install method: native
 └ Auto-updates enabled: true
 └ Update permissions: Yes
 └ Search: OK (vendor)
 Warning: Multiple installations found
 └ npm-global at ~/.nvm/versions/node/v23.11.0/bin/claude
 └ native at ~/.local/share/claude

修正開始

ネイティブインストール実行

いつ実行したかも忘れたので、再度ネイティブインストール実施。

curl -fsSL https://claude.ai/install.sh | bash
Setting up Claude Code...
✔  Claude Code successfully installed!
  Version: 1.0.86
  Location: ~/.local/bin/claude
  Next: Run claude --help to get started
✅ Installation complete!

インストール後の確認(まだ重複あり)

claude doctor

想定通り。さっきネイティブインストールは流したところ。npm版を削除しに行く。

 Diagnostics
 └ Currently running: npm-global (1.0.86)
 └ Path: ~/.nvm/versions/node/v23.11.0/bin/node
 └ Invoked: ~/.nvm/versions/node/v23.11.0/bin/claude
 └ Config install method: native
 └ Auto-updates enabled: true
 └ Update permissions: Yes
 └ Search: OK (vendor)
 Warning: Multiple installations found
 └ npm-global at ~/.nvm/versions/node/v23.11.0/bin/claude
 └ native at ~/.local/bin/claude

古いnpm版を削除

npm uninstall -g @anthropic-ai/claude-code
removed 3 packages in 317ms

PATH確認

echo $PATH
~/.nvm/versions/node/v23.11.0/bin:~/.local/bin:~/.nodebrew/current/bin:・・・

以下が含まれているのでOK。ここがネイティブインストールのclaude codeのシンボリックリンクの場所。
./local/bin

ネイティブ版の確認

問題なく見つけられているか確認。

which claude

OK

~/.local/bin/claude

最終確認(正常に完了)

claude doctor
 Diagnostics
 └ Currently running: native (1.0.86)
 └ Path: ~/.local/bin/claude
 └ Invoked: ~/.local/share/claude/versions/1.0.86
 └ Config install method: native
 └ Auto-updates enabled: true
 └ Search: OK (bundled)

この手順で、npm版からnative版への移行が正常に完了し、警告メッセージも解消。

最後に

どこで重複状態になったかというと。思い当たる節としては、おかしくなったときに、claudeのfilesystemのmcpで環境不正を修正させた時に、勝手にやられてしまった気がする。
環境周りは自分で責任を持ってやろう(自戒)

1
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
1
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?