MCPcopy Index your code
hub / github.com/nodejs/node / writeInspectUsageAndExit

Function writeInspectUsageAndExit

lib/internal/debugger/inspect_helpers.js:64–134  ·  view source on GitHub ↗
(invokedAs, message, exitCode)

Source from the content-addressed store, hash-verified

62}
63
64function writeInspectUsageAndExit(invokedAs, message, exitCode) {
65 const code = exitCode ?? (message ? kInvalidCommandLineArgument : 0);
66 const out = code === 0 ? process.stdout : process.stderr;
67 if (message) {
68 out.write(`${message}\n`);
69 }
70 out.write(`Usage: ${invokedAs} [--port=<port>] [<node-option> ...]
71 [<script> [<script-args>] | <host>:<port> | -p <pid>]
72 ${invokedAs} --probe <file>:<line>[:<col>] --expr <expr> [--max-hit <n>]
73 [--probe <file>:<line>[:<col>] --expr <expr> [--max-hit <n>] ...]
74 [--json] [--preview] [--timeout=<ms>] [--port=<port>]
75 [--] [<node-option> ...] <script> [<script-args> ...]
76
77Interactive mode: Starts a live debugging session.
78
79Example:
80 $ node inspect script.js
81
82Options:
83 --port=<port> Inspector port for the debuggee (default: 9229)
84 <script> The script to launch and debug.
85 <host>:<port> Remote debugger to connect to.
86 -p <pid> Attach to a running Node.js process by PID
87
88Semantics:
89* If neither a script nor a host:port nor -p is provided, node inspect starts
90 the REPL.
91
92Non-interactive probe mode: Evaluates expressions whenever execution reaches
93specified source locations and prints all the evaluation results to stdout.
94
95Example:
96 $ node inspect --probe app.js:10 --expr "user"
97 --probe src/utils.js:5:15 --expr "config.options"
98 --json --preview -- --no-warnings app.js --arg-for-app=foo
99
100Options:
101 --probe <file>:<line>[:<col>]
102 Source location of the probe. <file> is matched as a
103 path suffix of every loaded script URL, anchored on
104 a path separator. <line> and the optional <col> are
105 1-based. If <col> is omitted, the probe binds to
106 the first executable column on the line. This option
107 must be immediately followed by a pairing --expr.
108 --expr <expr> Expression to evaluate in the lexical scope of the
109 preceding --probe each time execution reaches it.
110 Avoid probing let/const-bound variables at their
111 declaration site or a ReferenceError may be thrown.
112 --max-hit <n> Per-probe limit on evaluated hits. When not specified,
113 there's no hit limit. When any probe reaches its hit LIMIT,
114 the probing process will detach and report the results.
115 The probed process will continue to run.
116 --json Output JSON if specified, otherwise human-readable text.
117 --preview Include V8 object previews in JSON output.
118 --timeout <ms> Global session timeout (default: 30000).
119 --port <port> Inspector port for the debuggee (default: 0 = random).
120
121Semantics:

Callers 1

startInspectFunction · 0.85

Calls 2

writeMethod · 0.45
exitMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…