Bug Description
claude remote-control fails immediately on Windows when Claude Code is installed via npm.
Error Message
[19:32:37] Session failed: C:\Program Files\nodejs\node.exe: bad option: --sdk-url session_01Ef7TU423PTCPcM2kCyj1uL
Root Cause
The bridge session spawner in cli.js uses process.execPath to spawn child sessions:
spawn(process.execPath, ["--print", "--sdk-url", url, "--session-id", id, ...])
On npm installs, process.execPath is node.exe (not the claude binary). Node.js interprets --print as its own -p flag (evaluate expression), then rejects --sdk-url as an invalid Node.js option.
On standalone binary installs (e.g., Homebrew), process.execPath IS the claude binary, so the flags are parsed correctly by Claude Code.
Environment
- OS: Windows 11 Pro 10.0.22631
- Node.js: v22.18.0
- Claude Code: 2.1.55 (installed via
npm install -g @anthropic-ai/claude-code)
- Shell: PowerShell / Git Bash
Workaround
Patch cli.js to insert process.argv[1] (path to cli.js) as the first spawn argument when running under Node.js:
Replace:
spawn(A.execPath, $, {cwd: K, stdio: ["pipe","pipe","pipe"], env: H, windowsHide: true})
With:
spawn(A.execPath, [...((/node(\.exe)?$/i).test(A.execPath) ? [process.argv[1]] : []), ...$], {cwd: K, stdio: ["pipe","pipe","pipe"], env: H, windowsHide: true})
This makes the spawn equivalent to what the npm shim does: node.exe cli.js --print --sdk-url ...
Suggested Fix
The bridge spawner should account for npm installs where process.execPath is the Node.js binary, not the Claude Code binary. Either include the script path in the spawn args, or resolve the claude command from PATH instead of using process.execPath.
Bug Description
claude remote-controlfails immediately on Windows when Claude Code is installed via npm.Error Message
Root Cause
The bridge session spawner in
cli.jsusesprocess.execPathto spawn child sessions:On npm installs,
process.execPathisnode.exe(not theclaudebinary). Node.js interprets--printas its own-pflag (evaluate expression), then rejects--sdk-urlas an invalid Node.js option.On standalone binary installs (e.g., Homebrew),
process.execPathIS theclaudebinary, so the flags are parsed correctly by Claude Code.Environment
npm install -g @anthropic-ai/claude-code)Workaround
Patch
cli.jsto insertprocess.argv[1](path tocli.js) as the first spawn argument when running under Node.js:Replace:
With:
This makes the spawn equivalent to what the npm shim does:
node.exe cli.js --print --sdk-url ...Suggested Fix
The bridge spawner should account for npm installs where
process.execPathis the Node.js binary, not the Claude Code binary. Either include the script path in the spawn args, or resolve theclaudecommand from PATH instead of usingprocess.execPath.