Claude Code 1.0.x安装

Claude Code:npm install -g 后 "claude: command not found"

claude: command not found
受影响版本
1.0.x
修复版本
最近验证
Claude Code 1.0.x

根因

全局 npm bin 目录不在 PATH 中,或安装时用了 sudo 导致 root 属主/错误软链接,shell 找不到 `claude` 可执行文件。

复现步骤

执行 `npm install -g @anthropic-ai/claude-code` 后,运行 `claude` 提示 command not found。

解决方案 (2)

按社区投票排序。应用前请先确认验证版本。

58
#1官方适用版本 1.0.x

不要用 sudo 安装。改用官方安装脚本:`curl -fsSL https://claude.ai/install.sh | bash`,可避免 root 属主的全局 npm 问题。

最近验证: Claude Code 1.0.x · maintainer

33
#2适用版本 1.0.x

把 npm 全局 bin 加入 PATH:运行 `npm config get prefix`,把 `<prefix>/bin` 加入 shell 配置(.zshrc/.bashrc)后重启 shell。

最近验证: Claude Code 1.0.x · community

来源

相关报错