diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 138fb52f861..e21fa81363a 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -695,6 +695,7 @@ changes: * `env` {Object} Environment key-value pairs. **Default:** `process.env`. * `argv0` {string} Explicitly set the value of `argv[0]` sent to the child process. This will be set to `command` if not specified. + * `execArgv` {string\[]} List of string arguments passed to the executable. * `stdio` {Array|string} Child's stdio configuration (see [`options.stdio`][`stdio`]). * `detached` {boolean} Prepare child process to run independently of diff --git a/lib/child_process.js b/lib/child_process.js index 887f5668e37..e517966147b 100644 --- a/lib/child_process.js +++ b/lib/child_process.js @@ -691,6 +691,13 @@ function normalizeSpawnArguments(file, args, options) { } } + // Handle execArgv - prepend to args if provided + if (options.execArgv != null) { + validateArray(options.execArgv, 'options.execArgv'); + validateArgumentsNullCheck(options.execArgv, 'options.execArgv'); + args = [...options.execArgv, ...args]; + } + if (typeof options.argv0 === 'string') { ArrayPrototypeUnshift(args, options.argv0); } else { @@ -788,6 +795,7 @@ function abortChildProcess(child, killSignal, reason) { * cwd?: string | URL; * env?: Record; * argv0?: string; + * execArgv?: string[]; * stdio?: Array | string; * detached?: boolean; * uid?: number;