node-inspect-debugger
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "node-inspect-debugger":https://skillpi.com/zh/skills/deepskill-4f76e05ac1cc268d774581b195303bb8b76b382c0bdd5b4e43af900376f82f95。安装前核对上游来源和版本:https://skillhub.cn/skills/user_ef9e183a/software-development-node-inspect-debugger。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
skillhub.cn
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
通过 --inspect 与 Chrome DevTools Protocol 的命令行工具,用于调试 Node.js 应用程序并进行远程或本地调试会话分析。
介绍来源: third_party · user_ef9e183a · 1.1.0 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 适合谁
- 翻译待完成,请参阅来源文档。
- 输入和输出
- 来源文档未说明。
- 软件、账号及付费要求
- 来源文档未说明。
- 限制与区别
- 来源文档未说明。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: node-inspect-debugger
description: Debug Node.js via --inspect + Chrome DevTools Protocol CLI.
version: 1.1.0
tags:
- debugging
- nodejs
- node-inspect
- cdp
- breakpoints
- electron
- vite
author: portedNode.js Inspect Debugger
Overview
When console.log isn't enough, drive Node's built-in V8 inspector programmatically from the terminal. You get real breakpoints, step in/over/out, call-stack walking, local/closure scope dumps, and arbitrary expression evaluation in the paused frame.
Two tools, pick one:
node inspect— built-in, zero install, CLI REPL. Best for quick poking.ndb/ CDP viachrome-remote-interface— scriptable from Node/Python; best when you want to automate many breakpoints, collect state across runs, or debug non-interactively from an agent loop.
Prefer node inspect first. It's always available and the REPL is fast.
In this repo the Node.js surfaces are the front-end packages — mateclaw-ui, mateclaw-webchat, and the Electron desktop app mateclaw-desktop. The Spring Boot backend is a JVM process and is not a target for this skill.
When to Use
- A Node-based build or packaging step (a Vite build, an
electron-builderhook, ascripts/helper) fails and you need to see intermediate state - The Electron desktop main process (
mateclaw-desktop) crashes, hangs on startup, or mishandles the bundled Java backend child process - A Vite dev server or a build plugin behaves wrong and
console.logcan't reach the value - You need to inspect a value in a closure that
console.logcan't reach without patching - Perf: attach to a running process to capture a CPU profile or heap snapshot
Don't use for: things console.log solves in under a minute. Breakpoint-driven debugging is heavier; use it when the payoff is real. The Electron renderer is a Chromium page, not a Node target — debug it with the window's built-in DevTools, not node inspect.
Quick Reference: node inspect REPL
Launch paused on first line:
node inspect path/to/script.js
# or with tsx
node --inspect-brk $(which tsx) path/to/script.ts
The debug> prompt accepts:
| Command | Action |
|---|---|
c or cont |
continue |
n or next |
step over |
s or step |
step into |
o or out |
step out |
pause |
pause running code |
sb('file.js', 42) |
set breakpoint at file.js line 42 |
sb(42) |
set breakpoint at line 42 of current file |
sb('functionName') |
break when function is called |
cb('file.js', 42) |
clear breakpoint |
breakpoints |
list all breakpoints |
bt |
backtrace (call stack) |
list(5) |
show 5 lines of source around current position |
watch('expr') |
evaluate expr on every pause |
watchers |
show watched expressions |
repl |
drop into REPL in current scope (Ctrl+C to exit REPL) |
exec expr |
evaluate expression once |
restart |
restart script |
kill |
kill the script |
.exit |
quit debugger |
In the repl sub-mode: type any JS expression, including access to locals/closure variables. Ctrl+C exits back to debug>.
Attaching to a Running Process
When the process is already running (e.g. a Vite dev server, or the Electron main process):
# 1. Send SIGUSR1 to enable the inspector on an existing process
kill -SIGUSR1 <pid>
# Node prints: Debugger listening on ws://127.0.0.1:9229/<uuid>
# 2. Attach the debugger CLI
node inspect -p <pid>
# or by URL
node inspect ws://127.0.0.1:9229/<uuid>
To start a process with the inspector from the beginning:
node --inspect script.js # listen on 127.0.0.1:9229, keep running
node --inspect-brk script.js # listen AND pause on first line
node --inspect=0.0.0.0:9230 script.js # custom host:port
For TypeScript via tsx:
node --inspect-brk --import tsx script.ts
# or older tsx
node --inspect-brk -r tsx/cjs script.ts
Programmatic CDP (scripting from terminal)
When you want to automate — set many breakpoints, capture scope state, script a repro — use chrome-remote-interface:
npm i -g chrome-remote-interface # or project-local
# Start your target:
node --inspect-brk=9229 target.js &
Driver script (save as /tmp/cdp-debug.js):
const CDP = require('chrome-remote-interface');
(async () => {
const client = await CDP({ port: 9229 });
const { Debugger, Runtime } = client;
Debugger.paused(async ({ callFrames, reason }) => {
const top = callFrames[0];
console.log(`PAUSED: ${reason} @ ${top.url}:${top.location.lineNumber + 1}`);
// Walk scopes for locals
for (const scope of top.scopeChain) {
if (scope.type === 'local' || scope.type === 'closure') {
const { result } = await Runtime.getProperties({
objectId: scope.object.objectId,
ownProperties: true,
});
for (const p of result) {
console.log(` ${scope.type}.${p.name} =`, p.value?.value ?? p.value?.description);
}
}
}
// Evaluate an expression in the paused frame
const { result } = await Debugger.evaluateOnCallFrame({
callFrameId: top.callFrameId,
expression: 'typeof state !== "undefined" ? JSON.stringify(state) : "n/a"',
});
console.log('state =', result.value ?? result.description);
await Debugger.resume();
});
await Runtime.enable();
await Debugger.enable();
// Set a breakpoint by URL regex + line
await Debugger.setBreakpointByUrl({
urlRegex: '.*dist-electron/main/index\\.js$',
lineNumber: 119, // 0-indexed
columnNumber: 0,
});
await Runtime.runIfWaitingForDebugger();
})();
Run it:
node /tmp/cdp-debug.js
chrome-remote-interface is not a dependency of any package in this repo. Install it to a throwaway location so you don't dirty a project's package.json:
mkdir -p /tmp/cdp-tools && cd /tmp/cdp-tools && npm i chrome-remote-interface
NODE_PATH=/tmp/cdp-tools/node_modules node /tmp/cdp-debug.js
Debugging the Electron Desktop App
mateclaw-desktop is an Electron app. The main process is a Node process — electron/main/index.ts, compiled by Vite to dist-electron/main/index.js (the main field in package.json). It spawns the Java backend as a child process. The renderer is a Chromium BrowserWindow — debug that with the window's DevTools, not this skill.
Launch the main process paused
Electron forwards --inspect / --inspect-brk to its main process. Build the Electron output first so there is a dist-electron/ to run:
cd mateclaw-desktop
npm run build # produces dist/ and dist-electron/
npx electron --inspect-brk=9229 . # Electron starts, paused on the main process first line
# In another terminal:
node inspect ws://127.0.0.1:9229/<uuid>
Then inside debug>:
sb('dist-electron/main/index.js', 220) # e.g. the suspect line in window/backend setup
cont
When it pauses, repl → inspect mainWindow, javaProcess, BACKEND_PORT, the updater state, etc.
Attach to an already-running desktop app
The Electron main process is the one launched without a --type= flag (renderer/GPU/utility processes carry --type=):
# Find the main process PID (the entry without --type=)
ps aux | grep -i 'mateclaw-desktop' | grep -v -- '--type='
# Enable the inspector on it
kill -SIGUSR1 <main-pid>
# Find the WS URL and attach
curl -s http://127.0.0.1:9229/json/list | jq -r '.[0].webSocketDebuggerUrl'
node inspect ws://127.0.0.1:9229/<uuid>
The Java backend that the main process spawns is a JVM, not a Node target — it will not appear in /json/list. To debug that, use the JVM's own remote-debug flags, not this skill.
Debugging a Vite Dev Server
mateclaw-ui, mateclaw-webchat, and mateclaw-desktop all run vite for dev. To step through Vite config or a build plugin, run Vite's binary under the inspector instead of the pnpm dev wrapper:
cd mateclaw-ui
node --inspect-brk ./node_modules/vite/bin/vite.js
# In another terminal: node inspect -p <pid>, then sb('vite.config.ts', N), cont
This pauses inside the Node process that loads vite.config.ts and runs plugin hooks. The browser-side Vue code it serves is not reachable here — that runs in the browser and is debugged with browser DevTools.
Heap Snapshots & CPU Profiles (Non-interactive)
From the CDP driver above, swap Debugger for HeapProfiler / Profiler:
// CPU profile for 5 seconds
await client.Profiler.enable();
await client.Profiler.start();
await new Promise(r => setTimeout(r, 5000));
const { profile } = await client.Profiler.stop();
require('fs').writeFileSync('/tmp/cpu.cpuprofile', JSON.stringify(profile));
// Open /tmp/cpu.cpuprofile in Chrome DevTools → Performance tab
// Heap snapshot
await client.HeapProfiler.enable();
const chunks = [];
client.HeapProfiler.addHeapSnapshotChunk(({ chunk }) => chunks.push(chunk));
await client.HeapProfiler.takeHeapSnapshot({ reportProgress: false });
require('fs').writeFileSync('/tmp/heap.heapsnapshot', chunks.join(''));
Common Pitfalls
-
Wrong line numbers in TS source. Breakpoints hit the emitted JS, not the
.ts. Either (a) break in the built file (dist-electron/main/index.js), or (b) enable sourcemaps (node --enable-source-maps) and usesb('electron/main/index.ts', N)— but only with CDP clients that follow sourcemaps. Thenode inspectCLI does not. -
--inspectvs--inspect-brk.--inspectstarts the inspector but doesn't pause; your script races past your first breakpoint if you attach too late. Use--inspect-brkwhen you need to set breakpoints before any code runs. -
Port collisions. Default is
9229. If multiple Node processes are inspecting, pass--inspect=0(random port) and read the actual URL from/json/list:curl -s http://127.0.0.1:9229/json/list # lists all inspectable targets on the host -
Child processes.
--inspecton a parent does NOT inspect its children. Electron itself is multi-process, and the desktop main process additionally spawns the Java backend. UseNODE_OPTIONS='--inspect-brk' node parent.jsto propagate to every Node child; be aware they all need unique ports (Node auto-increments whenNODE_OPTIONS='--inspect'is inherited). -
Background kills. If you
Ctrl+Cout ofnode inspectwhile the target is paused, the target stays paused. Eithercontfirst, orkillthe target explicitly. -
Running
node inspectthrough the agent's shell tool. Theexecute_shell_commandtool is one-shot and non-interactive — it cannot drive the interactivedebug>REPL. For interactive stepping, runnode inspectin a real terminal yourself. For agent-driven debugging, prefer the scripted CDP driver above: it is fully non-interactive and runs fine as a singleexecute_shell_commandcall. -
Security.
--inspect=0.0.0.0:9229exposes arbitrary code execution. Always bind to127.0.0.1(the default) unless you have an isolated network.
Verification Checklist
After setting up a debug session, verify:
- [ ]
curl -s http://127.0.0.1:9229/json/listreturns exactly the target you expect - [ ] First breakpoint actually hits (if it doesn't, you likely missed
--inspect-brkor attached after execution completed) - [ ] Source listing at pause shows the right file (mismatch = sourcemap issue, see pitfall 1)
- [ ]
exec process.pidinreplreturns the PID you meant to attach to
One-Shot Recipes
"Why is this variable undefined at line X?"
node --inspect-brk script.js &
node inspect -p $!
# debug>
sb('script.js', X)
cont
# paused. Now:
repl
> myVariable
> Object.keys(this)
"What's the call path into this function?"
debug> sb('suspectFn')
debug> cont
# paused on entry
debug> bt
"This async chain hangs — where?"
# Start with --inspect (no -brk), let it run to the hang, then:
debug> pause
debug> bt
# Now you see the stuck frame当前收录版本
1.1.0
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- 提供 Node.js 调试的完整端到端方案,覆盖内置 inspect、CDP 脚本化、Electron/Vite 特定场景
- 解决开发者高频痛点:Electron 主进程崩溃、Vite 插件调试、闭包变量检查、性能分析
- 明确界定适用边界(不适用于 renderer 进程),避免误用
亮点
- description 精准描述核心功能(--inspect + CDP 调试 Node.js)
- tags 覆盖完整关键词:debugging/nodejs/node-inspect/cdp/breakpoints
- When to Use 章节清晰列举典型场景与排除场景,触发边界明确
待提升项
-
description 位置错位 原报告严重程度:轻微
description 写在 frontmatter 但未在 skill_body 开头重复
改进建议:在 skill_body 开头添加 description 摘要,提升可读性
-
章节标题层级 原报告严重程度:轻微
'When to Use' 为二级标题,建议提升为一级标题以匹配其他主章节
改进建议:将 'When to Use' 改为一级标题 '# When to Use',保持结构一致性
亮点
- 文档结构完整,含 Overview/Quick Reference/Attaching/Programmatic CDP/Electron/Vite/Pitfalls/Verification/Recipes 等清晰章节
- 每部分配有具体命令与端到端示例,frontmatter 完整,单文件约 480 行(<500 行限制)
亮点
- 所有命令均为标准 Node.js/Electron/Vite 官方用法,参数正确(--inspect-brk、SIGUSR1、CDP 端口)
- 覆盖主要异常场景:端口冲突、子进程调试、sourcemap 问题、后台进程残留
- 对不可逆操作(kill)有明确说明,CDP 脚本包含完整错误处理与资源释放结构
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
保存或修改文件
先确认输出目录和同名文件是否会被覆盖;重要文件保留备份,优先写入新的输出目录。
主文档提及 · 第 245, 255 行 -
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 112, 176, 191 行
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- 127.0.0.1
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
来源文档未说明。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。