bun-debug

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

/bun:debug

/bun:debug

Launch a script with Bun's debugger enabled for interactive debugging.
启动启用Bun调试器的脚本以进行交互式调试。

Parameters

参数

  • file
    (required): Script file to debug
  • --brk
    : Break at first line (for fast-exiting scripts)
  • --wait
    : Wait for debugger to attach before running
  • --port=<port>
    : Use specific port (default: auto-assigned)
  • file
    (必填):要调试的脚本文件
  • --brk
    :在第一行断点(适用于快速退出的脚本)
  • --wait
    :运行前等待调试器连接
  • --port=<port>
    :使用指定端口(默认:自动分配)

Execution

执行

Standard debug (opens debug URL):
bash
bun --inspect $FILE
Break at first line:
bash
bun --inspect-brk $FILE
Wait for debugger attachment:
bash
bun --inspect-wait $FILE
Custom port:
bash
bun --inspect=$PORT $FILE
Debug tests:
bash
bun --inspect-brk test $PATTERN
标准调试(打开调试URL):
bash
bun --inspect $FILE
在第一行断点:
bash
bun --inspect-brk $FILE
等待调试器连接:
bash
bun --inspect-wait $FILE
自定义端口:
bash
bun --inspect=$PORT $FILE
调试测试:
bash
bun --inspect-brk test $PATTERN

Output

输出

The command outputs a debug URL:
------------------- Bun Inspector -------------------
Listening: ws://localhost:6499/
Open: debug.bun.sh/#localhost:6499
-----------------------------------------------------
命令会输出一个调试URL:
------------------- Bun Inspector -------------------
Listening: ws://localhost:6499/
Open: debug.bun.sh/#localhost:6499
-----------------------------------------------------

Post-launch

启动后

  1. Report the debug URL to user
  2. Explain how to connect:
    • Open
      debug.bun.sh/#localhost:<port>
      in browser
    • Or use VSCode with Bun extension attached to the WebSocket URL
  3. Remind about breakpoint controls (F8 continue, F10 step over, F11 step into)
  1. 向用户报告调试URL
  2. 说明连接方式:
    • 在浏览器中打开
      debug.bun.sh/#localhost:<port>
    • 或者使用VSCode并通过WebSocket URL连接Bun扩展
  3. 提醒断点控制(F8继续,F10单步跳过,F11单步进入)

VSCode Integration

VSCode集成

For VSCode debugging, suggest adding to
.vscode/launch.json
:
json
{
  "type": "bun",
  "request": "launch",
  "name": "Debug",
  "program": "${file}",
  "stopOnEntry": true
}
对于VSCode调试,建议添加到
.vscode/launch.json
json
{
  "type": "bun",
  "request": "launch",
  "name": "Debug",
  "program": "${file}",
  "stopOnEntry": true
}