Package Exports
- @huksley/nodebugger
Readme
nodebugger
CLI to inspect running Node.js processes via V8 Inspector Protocol.
Install
npm install -g nodebuggerUsage
nodebugger [port] [command] [args]Start your Node.js app with inspector enabled:
node --inspect app.js
node --inspect=9230 app.jsInteractive mode:
nodebugger # REPL on default port 9229
nodebugger 9230 # REPL on port 9230Single command mode:
nodebugger eval "1+1"
nodebugger 9230 eval "process.pid"
nodebugger stack
nodebugger 9230 stackCommands
| Command | Short | Description |
|---|---|---|
eval <expr> |
e |
Evaluate JS expression in target process |
stack |
s |
Capture stack trace (pauses → dumps → resumes) |
pause |
p |
Pause execution |
resume |
r |
Resume execution |
exit |
q |
Disconnect and exit |
help |
? |
Show commands |
Unknown input is treated as eval.
Examples
> process.env.NODE_ENV
"production"
> Object.keys(require.cache).length
42
> stack
Stack Trace:
0: processTicksAndRejections (node:internal/process/task_queues:95:5)
1: runNextTicks (node:internal/process/task_queues:64:3)
> global.DEBUG = true
trueProgrammatic API
import { Inspector } from 'nodebugger';
const inspector = new Inspector(9229);
await inspector.connect();
const result = await inspector.eval('process.memoryUsage()');
console.log(result);
const stack = await inspector.getStackTrace();
console.log(stack);
await inspector.disconnect();API
new Inspector(port?, options?)- Create inspector instanceconnect()- Connect to target processeval(expression)- Evaluate JS expressionpause()- Pause executionresume()- Resume executiongetStackTrace()- Get current stack trace (pauses if needed)disconnect()- Clean disconnect
License
MIT