Claude CLI 安装报错记录(native binary not installed)

Claude CLI 安装报错记录(native binary not installed)

问题现象

安装 @anthropic-ai/claude-code 后执行 claude 报错:

sql 复制代码
Error: claude native binary not installed.                                    
                                                                                
  Either postinstall did not run (--ignore-scripts, some pnpm configs)          
  or the platform-native optional dependency was not downloaded                 
  (--omit=optional).                                                            
                                                                                
  Run the postinstall manually (adjust path for local vs global install):       
    node node_modules/@anthropic-ai/claude-code/install.cjs                     
                                                                                
  Or reinstall without --ignore-scripts / --omit=optional.                      

原因

npm 使用了国内 registry(如 npmmirror),该源未同步 optional binary,导致 native 依赖未下载。

排查

查看当前 npm registry

arduino 复制代码
npm config get registry

如果返回:

arduino 复制代码
https://registry.npmmirror.com

或:

arduino 复制代码
https://registry.npm.taobao.org

说明正在使用国内镜像源。

解决方法

切换官方源重新安装:

bash 复制代码
npm config set registry https://registry.npmjs.org/

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

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

或仅本次使用官方源(推荐):

bash 复制代码
npm install -g @anthropic-ai/claude-code --registry=https://registry.npmjs.org/

验证

css 复制代码
claude --version

能正常输出版本号即可,Have a try!。

相关推荐
搬砖小郭5 小时前
Claude Code安装+接入国产的模型
claude
jerrywus6 小时前
Claude Code 真正的用法:skill / agent / hooks / worktree 一篇全搞定
前端·agent·claude
deephub7 小时前
【无标题】
人工智能·prompt·大语言模型·claude
一乐小哥7 小时前
在claude code中使用codex来做codereview
gpt·claude
鸽芷咕8 小时前
【已解决】Claude Code 报错“claude.exe 与 Windows 不兼容“的解决方法
windows·claude
我是Superman丶8 小时前
Claude Code 启动失败修复指南
ai编程·claude
hlvy8 小时前
Claude Code 太难看?我开源了一个 Web GUI
前端·ai·claude
用户6757049885029 小时前
全网都在推 Claude Code,但只有这篇文章教你如何“真正”能用
后端·aigc·claude
倔强的石头_10 小时前
Claude-4.7与KYC风暴-中国AI从业者何去何从
claude