claude-code - 💡(How to fix) Fix v2.1.97 crashes on Linux x64 with Bun CommonJS module error [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#45541Fetched 2026-04-09 08:02:59
View on GitHub
Comments
0
Participants
1
Timeline
4
Reactions
0
Author
Participants
Timeline (top)
labeled ×4

Claude Code v2.1.97 fails to start on Linux x64 with a TypeError: Expected CommonJS module to have a function wrapper error from the embedded Bun runtime. v2.1.96 works fine.

Error Message

6 | "use strict"; 7 | 8 | // 9 | if (entry.instantiate) 10 | return entry.instantiate; 11 | var instantiatePromise = (async () => { ^ TypeError: Expected CommonJS module to have a function wrapper. If you weren't messing around with Bun's internals, this is a bug in Bun

Bun v1.3.11 (Linux x64 baseline)

Root Cause

  • Both v2.1.96 and v2.1.97 embed Bun v1.3.11, but different builds (different commit hashes):
    • v2.1.96: Bun v1.3.11 (6f0a17c3)
    • v2.1.97: Bun v1.3.11 (87b3dff3)
  • The v2.1.97 Bun build (87b3dff3) has a regression in CommonJS module loading within standalone compiled binaries.
  • The underlying cli.js from the npm package works perfectly when run via Node: node cli.js --version2.1.97 (Claude Code)
  • No environment variable (BUN_JSC_useJIT=0, BUN_RUNTIME_TRANSPILER_CACHE_PATH=0, BUN_CONFIG_NO_MACROS=true, etc.) resolves the issue.
  • Dynamic library dependencies are identical between the two versions.

Fix Action

Workaround

Extract cli.js from the npm package and run it via Node instead of the compiled Bun binary:

# Download and extract the npm package
cd /tmp && npm pack @anthropic-ai/[email protected]
tar xf anthropic-ai-claude-code-2.1.97.tgz

# Set up a Node-based installation
mkdir -p ~/.local/share/claude/node-versions/2.1.97
cp package/cli.js ~/.local/share/claude/node-versions/2.1.97/
cp -r package/vendor ~/.local/share/claude/node-versions/2.1.97/
echo '{"type": "module"}' > ~/.local/share/claude/node-versions/2.1.97/package.json

# Create a wrapper script
cat > ~/.local/share/claude/node-versions/2.1.97/claude-wrapper.sh << 'WRAPPER'
#!/usr/bin/env bash
exec node ~/.local/share/claude/node-versions/2.1.97/cli.js "$@"
WRAPPER
chmod +x ~/.local/share/claude/node-versions/2.1.97/claude-wrapper.sh

# Point the symlink to the wrapper
ln -sf ~/.local/share/claude/node-versions/2.1.97/claude-wrapper.sh ~/.local/bin/claude

Code Example

/home/$USER/.local/share/claude/versions/2.1.97 --version

---

6 |     "use strict";
 7 |
 8 |     //
 9 |     if (entry.instantiate)
10 |         return entry.instantiate;
11 |     var instantiatePromise = (async () => {
                                               ^
TypeError: Expected CommonJS module to have a function wrapper. If you weren't messing around with Bun's internals, this is a bug in Bun

Bun v1.3.11 (Linux x64 baseline)

---

# Download and extract the npm package
cd /tmp && npm pack @anthropic-ai/claude-code@2.1.97
tar xf anthropic-ai-claude-code-2.1.97.tgz

# Set up a Node-based installation
mkdir -p ~/.local/share/claude/node-versions/2.1.97
cp package/cli.js ~/.local/share/claude/node-versions/2.1.97/
cp -r package/vendor ~/.local/share/claude/node-versions/2.1.97/
echo '{"type": "module"}' > ~/.local/share/claude/node-versions/2.1.97/package.json

# Create a wrapper script
cat > ~/.local/share/claude/node-versions/2.1.97/claude-wrapper.sh << 'WRAPPER'
#!/usr/bin/env bash
exec node ~/.local/share/claude/node-versions/2.1.97/cli.js "$@"
WRAPPER
chmod +x ~/.local/share/claude/node-versions/2.1.97/claude-wrapper.sh

# Point the symlink to the wrapper
ln -sf ~/.local/share/claude/node-versions/2.1.97/claude-wrapper.sh ~/.local/bin/claude
RAW_BUFFERClick to expand / collapse

Description

Claude Code v2.1.97 fails to start on Linux x64 with a TypeError: Expected CommonJS module to have a function wrapper error from the embedded Bun runtime. v2.1.96 works fine.

Steps to reproduce

/home/$USER/.local/share/claude/versions/2.1.97 --version

Error output

 6 |     "use strict";
 7 |
 8 |     //
 9 |     if (entry.instantiate)
10 |         return entry.instantiate;
11 |     var instantiatePromise = (async () => {
                                               ^
TypeError: Expected CommonJS module to have a function wrapper. If you weren't messing around with Bun's internals, this is a bug in Bun

Bun v1.3.11 (Linux x64 baseline)

Analysis

  • Both v2.1.96 and v2.1.97 embed Bun v1.3.11, but different builds (different commit hashes):
    • v2.1.96: Bun v1.3.11 (6f0a17c3)
    • v2.1.97: Bun v1.3.11 (87b3dff3)
  • The v2.1.97 Bun build (87b3dff3) has a regression in CommonJS module loading within standalone compiled binaries.
  • The underlying cli.js from the npm package works perfectly when run via Node: node cli.js --version2.1.97 (Claude Code)
  • No environment variable (BUN_JSC_useJIT=0, BUN_RUNTIME_TRANSPILER_CACHE_PATH=0, BUN_CONFIG_NO_MACROS=true, etc.) resolves the issue.
  • Dynamic library dependencies are identical between the two versions.

Workaround

Extract cli.js from the npm package and run it via Node instead of the compiled Bun binary:

# Download and extract the npm package
cd /tmp && npm pack @anthropic-ai/[email protected]
tar xf anthropic-ai-claude-code-2.1.97.tgz

# Set up a Node-based installation
mkdir -p ~/.local/share/claude/node-versions/2.1.97
cp package/cli.js ~/.local/share/claude/node-versions/2.1.97/
cp -r package/vendor ~/.local/share/claude/node-versions/2.1.97/
echo '{"type": "module"}' > ~/.local/share/claude/node-versions/2.1.97/package.json

# Create a wrapper script
cat > ~/.local/share/claude/node-versions/2.1.97/claude-wrapper.sh << 'WRAPPER'
#!/usr/bin/env bash
exec node ~/.local/share/claude/node-versions/2.1.97/cli.js "$@"
WRAPPER
chmod +x ~/.local/share/claude/node-versions/2.1.97/claude-wrapper.sh

# Point the symlink to the wrapper
ln -sf ~/.local/share/claude/node-versions/2.1.97/claude-wrapper.sh ~/.local/bin/claude

Environment

  • OS: Ubuntu 24.04.3 LTS (Noble Numbat)
  • Kernel: 6.17.0-19-generic x86_64
  • glibc: 2.39
  • CPU: x86_64 with AVX2 support
  • Node: v25.9.0
  • Working version: 2.1.96 (same Bun v1.3.11 but commit 6f0a17c3)
  • Broken version: 2.1.97 (Bun v1.3.11 commit 87b3dff3)

extent analysis

TL;DR

The most likely fix is to extract cli.js from the npm package and run it via Node instead of the compiled Bun binary to avoid the regression in CommonJS module loading.

Guidance

  • The issue is caused by a regression in the Bun build (87b3dff3) used in Claude Code v2.1.97, which can be mitigated by using the Node-based installation approach.
  • To verify the fix, run the claude-wrapper.sh script and check that it executes without the TypeError: Expected CommonJS module to have a function wrapper error.
  • Ensure that the package.json file in the Node-based installation directory has the correct configuration, including {"type": "module"}, to enable ES module support.
  • If the workaround is successful, consider monitoring the Bun issue tracker for a fix to the regression in the 87b3dff3 build.

Example

The provided workaround script can be used as a starting point:

cat > ~/.local/share/claude/node-versions/2.1.97/claude-wrapper.sh << 'WRAPPER'
#!/usr/bin/env bash
exec node ~/.local/share/claude/node-versions/2.1.97/cli.js "$@"
WRAPPER

This script executes the cli.js file using Node, bypassing the compiled Bun binary.

Notes

This workaround may have performance implications, as it uses the Node interpreter instead of the compiled Bun binary. Additionally, this fix assumes that the cli.js file and its dependencies are compatible with the Node version being used (v25.9.0 in this case).

Recommendation

Apply the workaround by extracting cli.js from the npm package and running it via Node, as this approach has been verified to resolve the issue. This recommendation is based on the analysis of the regression in the Bun build (87b3dff3) and the successful execution of the cli.js file via Node.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING