From b62ed5a37e22b4414e28a5008ca201d700897d4c Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Fri, 8 May 2026 01:11:57 +0200 Subject: [PATCH] debugger: add --help to `node inspect` and improve docs - Add `--help` / `-h` to `node inspect` covering both interactive and non-interactive probe modes. The help text is printed when `--help`/`-h` appears before any positional argument to avoid hijacking `--help` passed to a child script. - Improve the documentation of probe mode and add examples, explain same-location probe coalescing, TDZ caveat for let/const bindings, basename matching and exit code behavior. Also move it to a section parallel to interactive mode. Remove recommendation of evaluating structured expressions as that is prone to missing info in JSON mode. Drive-by: When probe mode exits due to invalid arguments, exit with `kInvalidCommandLineArgument` (9) instead of `kGenericUserError` (1). Signed-off-by: Joyee Cheung --- doc/api/debugger.md | 387 ++++++++++++------ lib/internal/debugger/inspect.js | 77 +++- lib/internal/debugger/inspect_helpers.js | 74 +++- lib/internal/debugger/inspect_probe.js | 64 +-- .../test-debugger-inspect-help-forwarding.mjs | 34 ++ test/parallel/test-debugger-inspect-help.js | 37 ++ .../test-debugger-probe-missing-expr.js | 2 +- .../test-debugger-probe-requires-separator.js | 2 +- 8 files changed, 460 insertions(+), 217 deletions(-) create mode 100644 test/parallel/test-debugger-inspect-help-forwarding.mjs create mode 100644 test/parallel/test-debugger-inspect-help.js diff --git a/doc/api/debugger.md b/doc/api/debugger.md index 691b025c1d9929..43f713ad824206 100644 --- a/doc/api/debugger.md +++ b/doc/api/debugger.md @@ -10,6 +10,14 @@ Node.js includes a command-line debugging utility. The Node.js debugger client is not a full-featured debugger, but simple stepping and inspection are possible. +The debugger supports two modes of operation: [interactive mode][] and [non-interactive probe mode][]. + +## Interactive mode + +```console +$ node inspect [--port=] [ ...] [