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

相关推荐
むはちひつなゃ初见2 小时前
LLM API成本控制:按业务风险路由Claude/GPT/Gemini
claude·openai兼容·llm api
plainGeekDev3 小时前
Agent Prompt 怎么写:三个真实案例讲透
agent·ai编程·claude
babytiger7 小时前
Orange Pi 完全可以作为一个 ARM64 的 Codex / Claude Code 用 opencode开发终端来用
claude·opencode
Flynt1 天前
给Claude Code装了70行规矩,生成的代码终于不用大改了
ai编程·claude
JavaGuide1 天前
万字详解Claude Code Hooks :生命周期钩子与自动化工作流
ai编程·claude
钱多多_qdd1 天前
claude code(十六):【企业级应用实战】案例七:安全风险&代码审查新挑战&总结
ai·claude
钱多多_qdd1 天前
claude code(十五):【企业级应用实战】案例六:快速理解和改造开源项目11个技巧让 Claude Code 成功率翻倍
ai·claude
benchmark_cc1 天前
Claude Code + MCP + QuantDash:打造全自动量化研究流水线的终极指南
人工智能·后端·爬虫·算法·claude·mcp·quantdash
icestone20001 天前
从Cursor到Claude Code:一年半AI编程实战经验
ai编程·claude·cursor