词元之母TOK.MOM - 平台充值汇率 1:1 即 1 人民币充值到账 1 美元,支持一个 Key 调用近 600+ 海内外模型,限时特价模型低至 1 折,欢迎上岸!
| 来源 | 内置(默认安装) |
| 路径 | skills/software-development/node-inspect-debugger |
| 版本 | 1.0.0 |
| 作者 | Hermes Agent |
| 许可证 | MIT |
| 平台 | linux, macos, windows |
| 标签 | debugging, nodejs, node-inspect, cdp, breakpoints, ui-tui |
| 相关 skill | systematic-debugging, python-debugpy, debugging-hermes-tui-commands |
console.log 不够用时,可以从终端以编程方式驱动 Node 内置的 V8 inspector。你可以使用真正的断点、单步执行(step in/over/out)、调用栈遍历、局部变量/闭包作用域转储,以及在暂停帧中执行任意表达式求值。node inspect — 内置,无需安装,CLI REPL(交互式命令行)。适合快速探查。ndb / CDP via chrome-remote-interface — 可从 Node/Python 脚本化调用;适合需要自动化设置大量断点、跨多次运行收集状态,或在 agent 循环中非交互式调试的场景。node inspect。 它始终可用,REPL 响应快。_SlashWorker、PTY bridge workers)行为异常console.log 获取console.log 就能解决的问题。断点调试开销较大,只在收益明显时使用。node inspect REPLdebug> 提示符接受以下命令:| 命令 | 操作 |
|---|---|
c 或 cont | 继续执行 |
n 或 next | 单步跳过 |
s 或 step | 单步进入 |
o 或 out | 单步跳出 |
pause | 暂停运行中的代码 |
sb('file.js', 42) | 在 file.js 第 42 行设置断点 |
sb(42) | 在当前文件第 42 行设置断点 |
sb('functionName') | 在函数被调用时中断 |
cb('file.js', 42) | 清除断点 |
breakpoints | 列出所有断点 |
bt | 回溯(调用栈) |
list(5) | 显示当前位置前后各 5 行源码 |
watch('expr') | 每次暂停时求值 expr |
watchers | 显示监视表达式 |
repl | 在当前作用域进入 REPL(Ctrl+C 退出 REPL) |
exec expr | 单次求值表达式 |
restart | 重启脚本 |
kill | 终止脚本 |
.exit | 退出调试器 |
repl 子模式中: 输入任意 JS 表达式,包括访问局部变量/闭包变量。Ctrl+C 返回 debug>。chrome-remote-interface:/tmp/cdp-debug.js):chrome-remote-interface 不在 ui-tui/package.json 中。如果不想污染项目,可将其安装到临时目录:ui-tui/package.json 有 npm run dev(tsx --watch)。直接运行 tsx 并添加 --inspect-brk:debug> 中:sb('dist/app.js', 220) # or wherever the suspect render is
contrepl → 检查 props、state 引用、useInput 处理器的值等。hermes --tuisb(...) 处暂停它。_SlashWorker / PTY 子进程python-debugpy skill。只有 Node 部分(Ink UI、tui_gateway client、ui-tui/ 下的 tsx-run 测试)使用本 skill。