[BUG] TypeScript SDK fails when using pathToClaudeCodeExecutable with native binary installation
Resolved 💬 5 comments Opened Aug 15, 2025 by sugyan Closed Sep 4, 2025
Environment
- Platform (select one):
- [x] Anthropic API
- [ ] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: 1.0.81
- Operating System: macOS 15.6
- Terminal: WezTerm
Bug Description
TypeScript SDK fails to execute when using pathToClaudeCodeExecutable option pointing to native binary installation of Claude Code.
Steps to Reproduce
- Install Claude Code using native binary installation:
curl -fsSL https://claude.ai/install.sh | bash - Create TypeScript file with SDK code using
pathToClaudeCodeExecutable: "/Users/username/.local/bin/claude" - Run the TypeScript file
Expected Behavior
The SDK should successfully execute queries using the native binary installation.
Actual Behavior
Spawning Claude Code process: node /Users/username/.local/bin/claude --output-format stream-json --verbose --print -- hello
Claude Code stderr: /Users/username/.local/share/claude/versions/1.0.81:1
����
SyntaxError: Invalid or unexpected token
at wrapSafe (node:internal/modules/cjs/loader:1624:18)
at Module._compile (node:internal/modules/cjs/loader:1666:20)
at Object..js (node:internal/modules/cjs/loader:1824:10)
at Module.load (node:internal/modules/cjs/loader:1427:32)
at Module._load (node:internal/modules/cjs/loader:1250:12)
at TracingChannel.traceSync (node:diagnostics_channel:322:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:235:24)
at Module.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:152:5)
at node:internal/main/run_main_module:33:47
Node.js v24.3.0
...
Additional Context
Code example:
import { query } from "@anthropic-ai/claude-code";
(async function () {
for await (const message of query({
prompt: "hello",
options: {
pathToClaudeCodeExecutable: "/Users/username/.local/bin/claude",
},
})) {
console.log(JSON.stringify(message, null, 2));
}
})();
This issue occurs specifically with native binary installation. The same code works with npm-installed Claude Code.
Question: Is this a bug that can be fixed, or is it an intentional limitation where the TypeScript SDK is designed to work only with npm-installed Claude Code and not with native binary installations? If it's a limitation, it would be helpful to document this in the SDK documentation to clarify compatibility requirements.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗