Skip to content

npm vs Standalone Binary for Claude Code: Which Should You Use?

Problem

I was using Claude Code’s standalone binary on Linux, and I noticed something strange in my API requests. The binary was rewriting a sentinel value cch=85c62 in every outgoing request.

If my conversation happened to contain this specific string pattern, it would break the cache prefix. This is a subtle bug that can cause unexpected behavior in caching and request handling.

What happened?

I had installed Claude Code using the standalone binary method, which downloads a self-contained executable to ~/.local/share/claude/. Everything seemed fine until I started investigating caching issues.

Here’s what my installation looked like:

/home/user/.local/share/claude/claude
# Check which version is installed
which claude

When I inspected the API requests, I found that the standalone binary uses a custom Bun fork. This fork has a sentinel value replacement mechanism that rewrites cch=85c62 in every request.

The problem: if my conversation text contains this exact string, the replacement corrupts the cache prefix. This is the second bug found in the standalone binary.

On Reddit, another user (Rick-D-99) commented: “I use the npm version by default on linux… guess my process saved me from the dreaded bugs.”

Two Installation Methods

Claude Code offers two ways to install:

MethodHow it WorksWhat it Uses
npmnpm install @anthropic-ai/claude-codePure Node.js
Standalone BinaryDownload from releasesCustom Bun fork

The standalone binary seems convenient - it’s self-contained and simple to install. But the npm version has distinct advantages.

Why npm is Better

After switching to the npm version, I found several benefits:

  1. No sentinel replacement bug - The npm version runs pure Node.js without the custom Bun fork modifications
  2. Easier to patch - The cli.js file is readable JavaScript, so you can inspect and modify it if needed
  3. Version control - You can install specific versions with @version syntax
  4. No system-wide installation risk - Everything stays in a local directory

Here’s how I set up the npm version:

Terminal window
# Create a dedicated directory
mkdir -p ~/claude-npm && cd ~/claude-npm
# Install a specific version
npm install @anthropic-ai/[email protected]
# Run Claude Code
node node_modules/@anthropic-ai/claude-code/cli.js

To verify the installed version:

Terminal window
node -e "const p = require('./node_modules/@anthropic-ai/claude-code/package.json'); console.log(p.version)"
# Output: 2.1.81

Create a Wrapper Alias

Running the full node command every time is tedious. I created a shell alias:

Terminal window
# Add to ~/.bashrc or ~/.zshrc
alias claude-npm='node ~/claude-npm/node_modules/@anthropic-ai/claude-code/cli.js'

For a more permanent solution, I created a wrapper script:

~/.local/bin/claude-npm
#!/usr/bin/env bash
exec node ~/claude-npm/node_modules/@anthropic-ai/claude-code/cli.js "$@"
Terminal window
# Make it executable
chmod +x ~/.local/bin/claude-npm
# Verify it works
which claude-npm
# Output: /home/user/.local/bin/claude-npm

Comparison: npm vs Binary

AspectnpmStandalone Binary
Bug riskNo sentinel bugHas sentinel replacement bug
PatchabilityEasy (readable JS)Hard (compiled binary)
Version controlPin any versionLimited options
DependenciesRequires Node.jsSelf-contained
Setup complexitySlightly more stepsSingle download

Common Mistakes to Avoid

I made these mistakes initially:

  • Using the standalone binary by default without knowing about the sentinel bug
  • Not checking which version was actually running
  • Mixing installation methods, causing confusion about which one was active

To check what you’re running:

Terminal window
which claude
# ~/.local/share/claude/claude = standalone binary
# ~/.local/bin/claude-npm = npm version (wrapper)

The Reason

The standalone binary is built with a custom Bun fork that implements sentinel value replacement for optimization purposes. However, this mechanism inadvertently rewrites the string cch=85c62 wherever it appears in the request payload.

This is problematic because:

  • If your conversation contains this exact pattern, the replacement corrupts the cache prefix
  • The bug is subtle and hard to detect
  • It affects caching behavior in unpredictable ways

The npm version runs the same code through standard Node.js without this modification, avoiding the issue entirely.

Summary

In this post, I explained why the npm installation method is preferable for Claude Code. The standalone binary has a sentinel value replacement bug in its custom Bun fork that can break cache prefixes. The npm version avoids this issue and offers better patchability and version control. The key takeaway: use npm install @anthropic-ai/claude-code and run it via node cli.js.

Final Words + More Resources

My intention with this article was to help others share my knowledge and experience. If you want to contact me, you can contact by email: Email me

Here are also the most important links from this article along with some further resources that will help you in this scope:

Oh, and if you found these resources useful, don’t forget to support me by starring the repo on GitHub!

Comments