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!。

相关推荐
乘风gg21 小时前
AI 时代,你的编程能力在第几层?我敢说,大多数人卡在第一层
前端·ai编程·claude
码哥字节2 天前
我把 Karpathy 的 AI 编码准则,改造成了一套全栈开发的"工作流宪法",开源了
claude
凉凉的知识库3 天前
MCP 协议迎来重大升级:2026-07-28 新版核心变化速览
llm·claude·mcp
xiakq3 天前
5 分钟接入 GPT-5.6 完整指南
gpt·openai·claude·gemini·anthropic
yuanyxh3 天前
AI Agent 的使用进化史
agent·ai编程·claude
kyriewen3 天前
Claude自己跑出去hack了3家公司——我为什么还在用它写代码
前端·ai编程·claude
FantasticPerson4 天前
46 · 综合实战:从零到上线,把所学串成一条线
ai编程·claude
windliang4 天前
Claude Code 源码分析(四):Tool 工具系统-从 Schema 到真实执行
前端·ai编程·claude
Lumi_Peak4 天前
Claude思考了42秒,我的代码质量直接提升了一个档次
python·claude