[BUG] count_tokens.js glitches and breaks output due to the usage of import statement used while not in module mode.

Resolved 💬 3 comments Opened Jul 31, 2025 by mithileshchellappan Closed Aug 2, 2025

Environment

  • Platform (select one):
  • [x] Anthropic API
  • [ ] AWS Bedrock
  • [ ] Google Vertex AI
  • [ ] Other: <!-- specify -->
  • Claude CLI version: 1.0.64
  • Operating System: macOS 15.5
  • Terminal: Reproducible in Warp, Cursor Terminal and native mac terminal
  • Node.js: v22.5.1

Bug Description

The count_tokens.js file is using import while not in module type. This causes the error to appear on console for each message and breaks output of Claude making it unable to scroll.

Steps to Reproduce

There are no explicit steps to reproduce, every time a message is sent the count_tokens fails and the error is shown inline with claude output. The error would be at the very end of the message and new ones would start getting accumulated at the end (above input box) each time a message is sent. The terminal would also glitch each time a new token is added.

Expected Behavior

count_tokens.js works and does not throw an error inline with claude output

Actual Behavior

Every time a message is sent count_tokens.js fails and shows the import error in count_tokens.js file. Each time a new token comes in the terminal glitches, and when using ides like cursor when the glitch is too frequent, it causes the ide to crash and close.

Additional Context

https://github.com/user-attachments/assets/b1f60eb3-e4cc-4994-ab60-9585e1b011a1

<img width="1479" height="397" alt="Image" src="https://github.com/user-attachments/assets/612036f2-d4c1-40e0-b341-e4500d630366" />

<img width="1488" height="844" alt="Image" src="https://github.com/user-attachments/assets/0a39caba-cbcf-447e-995f-523a7d4845dd" />

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗