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?

macOS Claude Code「command not found」エラーの解決方法

Posted at

問題

npm install -g @anthropic-ai/claude-code後にclaude --versionで「command not found」エラー

原因

  • npmのbinディレクトリがPATHに含まれていない
  • シンボリックリンクが正しく作成されていない

解決手順

# 0. 既存のファイルを削除(クリーンアップ)
rm -f $(npm config get prefix)/bin/claude
rm -f $(npm config get prefix)/bin/.claude-*

# 1. PATHにnpm binを追加
echo 'export PATH="$(npm config get prefix)/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc

# 2. シンボリックリンクを手動作成
ln -sf $(npm config get prefix)/lib/node_modules/@anthropic-ai/claude-code/cli.js $(npm config get prefix)/bin/claude

# 3. 実行権限を付与
chmod +x $(npm config get prefix)/lib/node_modules/@anthropic-ai/claude-code/cli.js

# 4. 動作確認
claude --version
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?