解决 claude native binary not installed 错误

kaede@pc:~$ claude
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.

此时如果执行

node node_modules/@anthropic-ai/claude-code/install.cjs

会报错。这是因为最开始安装时是 npm install -g 安装的,需要调整路径。先获取全局路径:

kaede@pc:~$  npm root -g
/home/kaede/.nvm/versions/node/v24.22.0/lib/node_modules

再根据路径调整,即可运行 Claude Code。

kaede@pc:~$ node /home/kaede/.nvm/versions/node/v24.22.0/lib/node_modules/@anthropic-ai/claude-code/install.cjs
kaede@pc:~$ claude

添加新评论