[BUG] TypeScript SDK fails when using pathToClaudeCodeExecutable with native binary installation

Status Fixed / completed
Maintainer reply ✓ Yes — ant-kurt
Activity 5 comments · opened Aug 15, 2025 · closed Sep 4, 2025
💡 Likely answer: A maintainer (ant-kurt, collaborator) responded on this thread — see the highlighted reply below.

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

  1. Install Claude Code using native binary installation: curl -fsSL https://claude.ai/install.sh | bash
  2. Create TypeScript file with SDK code using pathToClaudeCodeExecutable: "/Users/username/.local/bin/claude"
  3. 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.

View original on GitHub ↗

5 Comments

github-actions[bot] · 1 year ago

Found 1 possible duplicate issue:

  1. https://github.com/anthropics/claude-code/issues/4383

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

ant-kurt collaborator · 1 year ago

Hi - right now we only support using the SDK with npm-installed Claude Code. We'll see if we can enable use with the native binary soon!

cbh123 · 1 year ago

Would love to see this supported! I'm seeing much faster response times from the native binary Claude Code, and it would be a huge help for my users not to have the npm dependency.

Let me know if there are any updates here!

blois collaborator · 1 year ago

This should now be supported, though you will need to provide a path to your own native binary.

github-actions[bot] · 1 year ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.