(invokedAs, message, exitCode)
| 62 | } |
| 63 | |
| 64 | function 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 | |
| 77 | Interactive mode: Starts a live debugging session. |
| 78 | |
| 79 | Example: |
| 80 | $ node inspect script.js |
| 81 | |
| 82 | Options: |
| 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 | |
| 88 | Semantics: |
| 89 | * If neither a script nor a host:port nor -p is provided, node inspect starts |
| 90 | the REPL. |
| 91 | |
| 92 | Non-interactive probe mode: Evaluates expressions whenever execution reaches |
| 93 | specified source locations and prints all the evaluation results to stdout. |
| 94 | |
| 95 | Example: |
| 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 | |
| 100 | Options: |
| 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 | |
| 121 | Semantics: |
no test coverage detected
searching dependent graphs…