claude code 安装报错claude native binary not installed.

2 阅读1分钟

最近安装遇到了这个问题:

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.

原因:

国内网络访问不到claude code的最新依赖包,而很多人在用国内镜像资源,但是国内镜像资源由于历史原因,国内镜像不会主动更新较大体积的包。所以下载下来的包出现了问题

解决方案很简单:

先在终端执行

npm config set registry [https://registry.npmjs.org](https://registry.npmjs.org/)

把npm镜像源改回官方源,再执行

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

问题完美解决

参考这个解决github.com