diff --git a/doc/api/process.md b/doc/api/process.md index eedbfeefdd7d40..f35c5350d42e8b 100644 --- a/doc/api/process.md +++ b/doc/api/process.md @@ -568,12 +568,12 @@ added: v0.1.27 * {string[]} -The `process.argv` property returns an array containing the command line -arguments passed when the Node.js process was launched. The first element will -be [`process.execPath`][]. See `process.argv0` if access to the original value -of `argv[0]` is needed. The second element will be the path to the JavaScript -file being executed. The remaining elements will be any additional command line -arguments. +The `process.argv` property returns an array in which the first element will be +[`process.execPath`][]. See `process.argv0` if access to the original value of +`argv[0]` is needed. The second element will be the path to the JavaScript file +being executed. The remaining elements will be any additional command line +arguments passed when the Node.js process was launched, same as +[`process.mainArgs`][]. For example, assuming the following script for `process-args.js`: @@ -1425,6 +1425,38 @@ process.kill(process.pid, 'SIGHUP'); When `SIGUSR1` is received by a Node.js process, Node.js will start the debugger. See [Signal Events][]. +## process.mainArgs + + +The `process.mainArgs` property returns an array containing the command line +arguments passed when the Node.js process was launched. + +For example, assuming the following script for `process-args.js`: + +```js +// print process.mainArgs +process.mainArgs.forEach((val, index) => { + console.log(`${index}: ${val}`); +}); +``` + +Launching the Node.js process as: + +```console +$ node process-args.js one two=three four +``` + +Would generate the output: + +```text +0: one +1: two=three +2: four +``` +* {string[]} + ## process.mainModule