Skip to content

[Bug]: OpenClaw installation fails for nvm/Homebrew users — sudo retry cannot find node #13333

@SiinXu

Description

@SiinXu

Issue Checklist\n\n- [x] I have searched through the existing issues and did not find a similar report.\n- [x] I have provided a short and descriptive title.\n\n### Platform\n\nmacOS\n\n### Version\n\nv1.7.24\n\n### Bug Description\n\nOpenClaw 一键安装在 macOS 上失败。安装过程中出现两个错误:\n\n1. 第一次 npm 安装失败(exit code 243):Electron 内部 spawn 的 npm 进程异常退出\n2. sudo 重试失败(exit code 127)@expo/sudo-prompt 提权后,root 的 PATH 不包含 nvm/homebrew 路径,导致 env: node: No such file or directory\n\n### Root Cause\n\nOpenClawService.ts 中构造 sudo 命令时,没有将 node 所在目录注入 PATH:\n\ntypescript\n// 当前代码\nconst npmCommand = `\"${npmPath}\" install -g openclaw@latest`\n// npm 的 shebang 是 #!/usr/bin/env node\n// sudo 环境的 PATH 只有 /usr/bin:/bin:/usr/sbin:/sbin\n// 找不到 node → env: node: No such file or directory\n\n\n### Fix\n\n在 sudo 命令前注入 node 目录到 PATH:\n\ntypescript\nconst nodeDir = path.dirname(npmPath)\nconst npmCommand = `export PATH=\"${nodeDir}:$PATH\" && \"${npmPath}\" install -g openclaw@latest`\n\n\n### Error Log\n\n\nInstalling OpenClaw with command: /usr/local/bin/npm install -g openclaw@latest\nOpenClaw install failed with code 243\nPermission denied, retrying with sudo-prompt...\nSudo install failed: Command failed: \"/usr/local/bin/npm\" install -g openclaw@latest\nenv: node: No such file or directory\n\n\n### Environment\n\n- macOS with nvm (node v24.14.0) + homebrew (node v25.8.0)\n- npm shebang: #!/usr/bin/env node\n- @expo/sudo-prompt uses osascript, root PATH doesn't include nvm/homebrew dirs\n\n### PR\n\n#13356

Metadata

Metadata

Assignees

No one assigned

    Labels

    OpenClawCherry Studio OpenClaw related issues

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions