Skip to content
Myr

api.md

This file

Path

docs/api.md

1,052 lines · 41.9 KiB · Markdown

Last changed by

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

History of this file

Take it

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 1–17why, one step back
1<picture>
2 <source media="(prefers-color-scheme: dark)" srcset="../media/logo_dark.svg">3 <img alt="execa logo" src="../media/logo.svg" width="400">4</picture>5<br>67# 📔 API reference89This lists all available [methods](#methods) and their [options](#options). This also describes the properties of the [subprocess](#subprocess), [result](#result) and [error](#execaerror) they return.1011## Methods1213### execa(file, arguments?, options?)1415`file`: `string | URL`\16`arguments`: `string[]`\17`options`: [`Options`](#options)\

Rename some types (#1009)ehmickybefore adoption2ef9186

line 18why, one step back
18_Returns_: [`ResultPromise`](#return-value)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 19–28why, one step back
19
20Executes a command using `file ...arguments`.2122More info on the [syntax](execution.md#array-syntax) and [escaping](escaping.md#array-syntax).2324### execa\`command\`25### execa(options)\`command\`2627`command`: `string`\28`options`: [`Options`](#options)\

Rename some types (#1009)ehmickybefore adoption2ef9186

line 29why, one step back
29_Returns_: [`ResultPromise`](#return-value)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 30–46why, one step back
30
31Executes a command. `command` is a [template string](execution.md#template-string-syntax) that includes both the `file` and its `arguments`.3233More info on the [syntax](execution.md#template-string-syntax) and [escaping](escaping.md#template-string-syntax).3435### execa(options)3637`options`: [`Options`](#options)\38_Returns_: [`execa`](#execafile-arguments-options)3940Returns a new instance of Execa but with different default [`options`](#options). Consecutive calls are merged to previous ones.4142[More info.](execution.md#globalshared-options)4344### execaSync(file, arguments?, options?)45### execaSync\`command\`46

Rename some types (#1009)ehmickybefore adoption2ef9186

line 47why, one step back
47_Returns_: [`SyncResult`](#return-value)

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

line 48why, one step back
48

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 49–59why, one step back
49Same as [`execa()`](#execafile-arguments-options) but synchronous.
5051Returns or throws a subprocess [`result`](#result). The [`subprocess`](#subprocess) is not returned: its methods and properties are not available.5253[More info.](execution.md#synchronous-execution)5455### $(file, arguments?, options?)5657`file`: `string | URL`\58`arguments`: `string[]`\59`options`: [`Options`](#options)\

Rename some types (#1009)ehmickybefore adoption2ef9186

line 60why, one step back
60_Returns_: [`ResultPromise`](#return-value)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 61–74why, one step back
61
62Same as [`execa()`](#execafile-arguments-options) but using [script-friendly default options](scripts.md#script-files).6364Just like `execa()`, this can use the [template string syntax](execution.md#template-string-syntax) or [bind options](execution.md#globalshared-options). It can also be [run synchronously](#execasyncfile-arguments-options) using `$.sync()` or `$.s()`.6566This is the preferred method when executing multiple commands in a script file.6768[More info.](scripts.md)6970### execaNode(scriptPath, arguments?, options?)7172`scriptPath`: `string | URL`\73`arguments`: `string[]`\74`options`: [`Options`](#options)\

Rename some types (#1009)ehmickybefore adoption2ef9186

line 75why, one step back
75_Returns_: [`ResultPromise`](#return-value)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 76–89why, one step back
76
77Same as [`execa()`](#execafile-arguments-options) but using the [`node: true`](#optionsnode) option.78Executes a Node.js file using `node scriptPath ...arguments`.7980Just like `execa()`, this can use the [template string syntax](execution.md#template-string-syntax) or [bind options](execution.md#globalshared-options).8182This is the preferred method when executing Node.js files.8384[More info.](node.md)8586### execaCommand(command, options?)8788`command`: `string`\89`options`: [`Options`](#options)\

Rename some types (#1009)ehmickybefore adoption2ef9186

line 90why, one step back
90_Returns_: [`ResultPromise`](#return-value)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 91–99why, one step back
91
92Executes a command. `command` is a string that includes both the `file` and its `arguments`.9394This is only intended for very specific cases, such as a [REPL](https://en.wikipedia.org/wiki/Read%E2%80%93eval%E2%80%93print_loop). This should be avoided otherwise.9596Just like `execa()`, this can [bind options](execution.md#globalshared-options). It can also be [run synchronously](#execasyncfile-arguments-options) using `execaCommandSync()`.9798[More info.](escaping.md#user-defined-input)99

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

line 100why, one step back
100## Return value

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 101why, one step back
101

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

lines 102–103why, one step back
102_TypeScript:_ [`ResultPromise`](typescript.md)\
103_Type:_ `Promise<object> | Subprocess`

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

line 104why, one step back
104

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 105why, one step back
105The return value of all [asynchronous methods](#methods) is both:

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

lines 106–107why, one step back
106- the [subprocess](#subprocess).
107- a `Promise` either resolving with its successful [`result`](#result), or rejecting with its [`error`](#execaerror).

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 108–110why, one step back
108
109[More info.](execution.md#subprocess)110

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

lines 111–112why, one step back
111## Subprocess
112

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

line 113why, one step back
113_TypeScript:_ [`Subprocess`](typescript.md)

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

lines 114–116why, one step back
114
115[`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) with the following methods and properties.116

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 117–159why, one step back
117### subprocess\[Symbol.asyncIterator\]()
118119_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)120121Subprocesses are [async iterables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator). They iterate over each output line.122123[More info.](lines.md#progressive-splitting)124125### subprocess.iterable(readableOptions?)126127`readableOptions`: [`ReadableOptions`](#readableoptions)\128_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)129130Same as [`subprocess[Symbol.asyncIterator]`](#subprocesssymbolasynciterator) except [options](#readableoptions) can be provided.131132[More info.](lines.md#progressive-splitting)133134### subprocess.pipe(file, arguments?, options?)135136`file`: `string | URL`\137`arguments`: `string[]`\138`options`: [`Options`](#options) and [`PipeOptions`](#pipeoptions)\139_Returns_: [`Promise<Result>`](#result)140141[Pipe](https://nodejs.org/api/stream.html#readablepipedestination-options) the subprocess' [`stdout`](#subprocessstdout) to a second Execa subprocess' [`stdin`](#subprocessstdin). This resolves with that second subprocess' [result](#result). If either subprocess is rejected, this is rejected with that subprocess' [error](#execaerror) instead.142143This follows the same syntax as [`execa(file, arguments?, options?)`](#execafile-arguments-options) except both [regular options](#options) and [pipe-specific options](#pipeoptions) can be specified.144145[More info.](pipe.md#array-syntax)146147### subprocess.pipe\`command\`148### subprocess.pipe(options)\`command\`149150`command`: `string`\151`options`: [`Options`](#options) and [`PipeOptions`](#pipeoptions)\152_Returns_: [`Promise<Result>`](#result)153154Like [`subprocess.pipe(file, arguments?, options?)`](#subprocesspipefile-arguments-options) but using a [`command` template string](scripts.md#piping-stdout-to-another-command) instead. This follows the same syntax as `execa` [template strings](execution.md#template-string-syntax).155156[More info.](pipe.md#template-string-syntax)157158### subprocess.pipe(secondSubprocess, pipeOptions?)159

Rename some types (#1009)ehmickybefore adoption2ef9186

line 160why, one step back
160`secondSubprocess`: [`ResultPromise`](#return-value)\

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 161–163why, one step back
161`pipeOptions`: [`PipeOptions`](#pipeoptions)\
162_Returns_: [`Promise<Result>`](#result)163

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

line 164why, one step back
164Like [`subprocess.pipe(file, arguments?, options?)`](#subprocesspipefile-arguments-options) but using the [return value](#return-value) of another [`execa()`](#execafile-arguments-options) call instead.

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 165–169why, one step back
165
166[More info.](pipe.md#advanced-syntax)167168#### pipeOptions169

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 170why, one step back
170_Type:_ `object`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 171–173why, one step back
171
172#### pipeOptions.from173

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 174–175why, one step back
174_Type:_ `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\
175_Default:_ `"stdout"`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 176–184why, one step back
176
177Which stream to pipe from the source subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.178179`"all"` pipes both [`stdout`](#subprocessstdout) and [`stderr`](#subprocessstderr). This requires the [`all`](#optionsall) option to be `true`.180181[More info.](pipe.md#source-file-descriptor)182183#### pipeOptions.to184

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 185–186why, one step back
185_Type:_ `"stdin" | "fd3" | "fd4" | ...`\
186_Default:_ `"stdin"`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 187–193why, one step back
187
188Which [stream](#subprocessstdin) to pipe to the destination subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.189190[More info.](pipe.md#destination-file-descriptor)191192#### pipeOptions.unpipeSignal193

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 194why, one step back
194_Type:_ [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 195–206why, one step back
195
196Unpipe the subprocess when the signal aborts.197198[More info.](pipe.md#unpipe)199200### subprocess.kill(signal, error?)201### subprocess.kill(error?)202203`signal`: `string | number`\204`error`: `Error`\205_Returns_: `boolean`206

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 207why, one step back
207Sends a [signal](https://nodejs.org/api/os.html#signal-constants) to the subprocess. The default signal is the [`killSignal`](#optionskillsignal) option. `killSignal` defaults to `SIGTERM`, which [terminates](#erroristerminated) the subprocess.

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 208–216why, one step back
208
209This returns `false` when the signal could not be sent, for example when the subprocess has already exited.210211When an error is passed as argument, it is set to the subprocess' [`error.cause`](#errorcause). The subprocess is then terminated with the default signal. This does not emit the [`error` event](https://nodejs.org/api/child_process.html#event-error).212213[More info.](termination.md)214215### subprocess.pid216

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 217why, one step back
217_Type:_ `number | undefined`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 218–251why, one step back
218
219Process identifier ([PID](https://en.wikipedia.org/wiki/Process_identifier)).220221This is `undefined` if the subprocess failed to spawn.222223[More info.](termination.md#inter-process-termination)224225### subprocess.send(message)226227`message`: `unknown`\228_Returns_: `boolean`229230Send a `message` to the subprocess. The type of `message` depends on the [`serialization`](#optionsserialization) option.231The subprocess receives it as a [`message` event](https://nodejs.org/api/process.html#event-message).232233This returns `true` on success.234235This requires the [`ipc`](#optionsipc) option to be `true`.236237[More info.](ipc.md#exchanging-messages)238239### subprocess.on('message', (message) => void)240241`message`: `unknown`242243Receives a `message` from the subprocess. The type of `message` depends on the [`serialization`](#optionsserialization) option.244The subprocess sends it using [`process.send(message)`](https://nodejs.org/api/process.html#processsendmessage-sendhandle-options-callback).245246This requires the [`ipc`](#optionsipc) option to be `true`.247248[More info.](ipc.md#exchanging-messages)249250### subprocess.stdin251

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 252why, one step back
252_Type:_ [`Writable | null`](https://nodejs.org/api/stream.html#class-streamwritable)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 253–261why, one step back
253
254The subprocess [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)) as a stream.255256This is `null` if the [`stdin`](#optionsstdin) option is set to [`'inherit'`](input.md#terminal-input), [`'ignore'`](input.md#ignore-input), [`Readable`](streams.md#input) or [`integer`](input.md#terminal-input).257258[More info.](streams.md#manual-streaming)259260### subprocess.stdout261

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 262why, one step back
262_Type:_ [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 263–271why, one step back
263
264The subprocess [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) as a stream.265266This is `null` if the [`stdout`](#optionsstdout) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.267268[More info.](streams.md#manual-streaming)269270### subprocess.stderr271

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 272why, one step back
272_Type:_ [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 273–281why, one step back
273
274The subprocess [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)) as a stream.275276This is `null` if the [`stderr`](#optionsstdout) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.277278[More info.](streams.md#manual-streaming)279280### subprocess.all281

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 282why, one step back
282_Type:_ [`Readable | undefined`](https://nodejs.org/api/stream.html#class-streamreadable)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 283–293why, one step back
283
284Stream combining/interleaving [`subprocess.stdout`](#subprocessstdout) and [`subprocess.stderr`](#subprocessstderr).285286This requires the [`all`](#optionsall) option to be `true`.287288This is `undefined` if [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr) options are set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.289290More info on [interleaving](output.md#interleaved-output) and [streaming](streams.md#manual-streaming).291292### subprocess.stdio293

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 294why, one step back
294_Type:_ [`[Writable | null, Readable | null, Readable | null, ...Array<Writable | Readable | null>]`](https://nodejs.org/api/stream.html#class-streamreadable)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 295–312why, one step back
295
296The subprocess [`stdin`](#subprocessstdin), [`stdout`](#subprocessstdout), [`stderr`](#subprocessstderr) and [other files descriptors](#optionsstdio) as an array of streams.297298Each array item is `null` if the corresponding [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) or [`stdio`](#optionsstdio) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Stream`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.299300[More info.](streams.md#manual-streaming)301302### subprocess.readable(readableOptions?)303304`readableOptions`: [`ReadableOptions`](#readableoptions)\305_Returns_: [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable) Node.js stream306307Converts the subprocess to a readable stream.308309[More info.](streams.md#converting-a-subprocess-to-a-stream)310311#### readableOptions312

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 313why, one step back
313_Type:_ `object`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 314–316why, one step back
314
315#### readableOptions.from316

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 317–318why, one step back
317_Type:_ `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\
318_Default:_ `"stdout"`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 319–327why, one step back
319
320Which stream to read from the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.321322`"all"` reads both [`stdout`](#subprocessstdout) and [`stderr`](#subprocessstderr). This requires the [`all`](#optionsall) option to be `true`.323324[More info.](streams.md#different-file-descriptor)325326#### readableOptions.binary327

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 328–329why, one step back
328_Type:_ `boolean`\
329_Default:_ `false` with [`subprocess.iterable()`](#subprocessiterablereadableoptions), `true` with [`subprocess.readable()`](#subprocessreadablereadableoptions)/[`subprocess.duplex()`](#subprocessduplexduplexoptions)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 330–340why, one step back
330
331If `false`, iterates over lines. Each line is a string.332333If `true`, iterates over arbitrary chunks of data. Each line is an [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array) (with [`subprocess.iterable()`](#subprocessiterablereadableoptions)) or a [`Buffer`](https://nodejs.org/api/buffer.html#class-buffer) (with [`subprocess.readable()`](#subprocessreadablereadableoptions)/[`subprocess.duplex()`](#subprocessduplexduplexoptions)).334335This is always `true` when the [`encoding`](#optionsencoding) option is binary.336337More info for [iterables](binary.md#iterable) and [streams](binary.md#streams).338339#### readableOptions.preserveNewlines340

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 341–342why, one step back
341_Type:_ `boolean`\
342_Default:_ `false` with [`subprocess.iterable()`](#subprocessiterablereadableoptions), `true` with [`subprocess.readable()`](#subprocessreadablereadableoptions)/[`subprocess.duplex()`](#subprocessduplexduplexoptions)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 343–358why, one step back
343
344If both this option and the [`binary`](#readableoptionsbinary) option is `false`, [newlines](https://en.wikipedia.org/wiki/Newline) are stripped from each line.345346[More info.](lines.md#iterable)347348### subprocess.writable(writableOptions?)349350`writableOptions`: [`WritableOptions`](#writableoptions)\351_Returns_: [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable) Node.js stream352353Converts the subprocess to a writable stream.354355[More info.](streams.md#converting-a-subprocess-to-a-stream)356357#### writableOptions358

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 359why, one step back
359_Type:_ `object`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 360–362why, one step back
360
361#### writableOptions.to362

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 363–364why, one step back
363_Type:_ `"stdin" | "fd3" | "fd4" | ...`\
364_Default:_ `"stdin"`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 365–380why, one step back
365
366Which [stream](#subprocessstdin) to write to the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.367368[More info.](streams.md#different-file-descriptor)369370### subprocess.duplex(duplexOptions?)371372`duplexOptions`: [`ReadableOptions | WritableOptions`](#readableoptions)\373_Returns_: [`Duplex`](https://nodejs.org/api/stream.html#class-streamduplex) Node.js stream374375Converts the subprocess to a duplex stream.376377[More info.](streams.md#converting-a-subprocess-to-a-stream)378379## Result380

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

line 381why, one step back
381_TypeScript:_ [`Result`](typescript.md) or [`SyncResult`](typescript.md\

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 382why, one step back
382_Type:_ `object`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 383why, one step back
383

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 384why, one step back
384[Result](execution.md#result) of a subprocess successful execution.

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 385–389why, one step back
385
386When the subprocess [fails](errors.md#subprocess-failure), it is rejected with an [`ExecaError`](#execaerror) instead.387388### result.stdout389

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 390why, one step back
390_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 391–401why, one step back
391
392The output of the subprocess on [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)).393394This is `undefined` if the [`stdout`](#optionsstdout) option is set to only [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.395396This is an array if the [`lines`](#optionslines) option is `true`, or if the `stdout` option is a [transform in object mode](transform.md#object-mode).397398[More info.](output.md#stdout-and-stderr)399400### result.stderr401

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 402why, one step back
402_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 403–413why, one step back
403
404The output of the subprocess on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)).405406This is `undefined` if the [`stderr`](#optionsstderr) option is set to only [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.407408This is an array if the [`lines`](#optionslines) option is `true`, or if the `stderr` option is a [transform in object mode](transform.md#object-mode).409410[More info.](output.md#stdout-and-stderr)411412### result.all413

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 414why, one step back
414_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 415–427why, one step back
415
416The output of the subprocess with [`result.stdout`](#resultstdout) and [`result.stderr`](#resultstderr) interleaved.417418This requires the [`all`](#optionsall) option to be `true`.419420This is `undefined` if both [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr) options are set to only [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.421422This is an array if the [`lines`](#optionslines) option is `true`, or if either the `stdout` or `stderr` option is a [transform in object mode](transform.md#object-mode).423424[More info.](output.md#interleaved-output)425426### result.stdio427

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 428why, one step back
428_Type:_ `Array<string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined>`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 429–439why, one step back
429
430The output of the subprocess on [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) and [other file descriptors](#optionsstdio).431432Items are `undefined` when their corresponding [`stdio`](#optionsstdio) option is set to [`'inherit'`](output.md#terminal-output), [`'ignore'`](output.md#ignore-output), [`Writable`](streams.md#output) or [`integer`](output.md#terminal-output), or if the [`buffer`](#optionsbuffer) option is `false`.433434Items are arrays when their corresponding `stdio` option is a [transform in object mode](transform.md#object-mode).435436[More info.](output.md#additional-file-descriptors)437438### result.pipedFrom439

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 440why, one step back
440_Type:_ [`Array<Result | ExecaError>`](#result)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 441–449why, one step back
441
442[Results](#result) of the other subprocesses that were piped into this subprocess.443444This array is initially empty and is populated each time the [`subprocess.pipe()`](#subprocesspipefile-arguments-options) method resolves.445446[More info.](pipe.md#result)447448### result.command449

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 450why, one step back
450_Type:_ `string`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 451–457why, one step back
451
452The file and [arguments](input.md#command-arguments) that were run.453454[More info.](debugging.md#command)455456### result.escapedCommand457

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 458why, one step back
458_Type:_ `string`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 459–465why, one step back
459
460Same as [`command`](#resultcommand) but escaped.461462[More info.](debugging.md#command)463464### result.cwd465

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 466why, one step back
466_Type:_ `string`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 467–473why, one step back
467
468The [current directory](#optionscwd) in which the command was run.469470[More info.](environment.md#current-directory)471472### result.durationMs473

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 474why, one step back
474_Type:_ `number`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 475–481why, one step back
475
476Duration of the subprocess, in milliseconds.477478[More info.](debugging.md#duration)479480### result.failed481

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 482why, one step back
482_Type:_ `boolean`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 483–485why, one step back
483
484Whether the subprocess failed to run.485

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

lines 486–487why, one step back
486When this is `true`, the result is an [`ExecaError`](#execaerror) instance with additional error-related properties.
487

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 488–489why, one step back
488[More info.](errors.md#subprocess-failure)
489

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

lines 490–491why, one step back
490## ExecaError
491## ExecaSyncError

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 492why, one step back
492

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 493why, one step back
493_Type:_ `Error`

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

lines 494–504why, one step back
494
495Result of a subprocess [failed execution](errors.md#subprocess-failure).496497This error is thrown as an exception. If the [`reject`](#optionsreject) option is false, it is returned instead.498499This has the same shape as [successful results](#result), with the following additional properties.500501[More info.](errors.md)502503### error.message504

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 505why, one step back
505_Type:_ `string`

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

lines 506–512why, one step back
506
507Error message when the subprocess [failed](errors.md#subprocess-failure) to run.508509[More info.](errors.md#error-message)510511### error.shortMessage512

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 513why, one step back
513_Type:_ `string`

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

lines 514–520why, one step back
514
515This is the same as [`error.message`](#errormessage) except it does not include the subprocess [output](output.md).516517[More info.](errors.md#error-message)518519### error.originalMessage520

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 521why, one step back
521_Type:_ `string | undefined`

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

lines 522–528why, one step back
522
523Original error message. This is the same as [`error.message`](#errormessage) excluding the subprocess [output](output.md) and some additional information added by Execa.524525[More info.](errors.md#error-message)526527### error.cause528

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 529why, one step back
529_Type:_ `unknown | undefined`

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

lines 530–538why, one step back
530
531Underlying error, if there is one. For example, this is set by [`subprocess.kill(error)`](#subprocesskillerror).532533This is usually an `Error` instance.534535[More info.](termination.md#error-message-and-stack-trace)536537### error.code538

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 539why, one step back
539_Type:_ `string | undefined`

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

lines 540–544why, one step back
540
541Node.js-specific [error code](https://nodejs.org/api/errors.html#errorcode), when available.542543### error.timedOut544

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 545why, one step back
545_Type:_ `boolean`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 546–550why, one step back
546
547Whether the subprocess timed out due to the [`timeout`](#optionstimeout) option.548549[More info.](termination.md#timeout)550

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 551why, one step back
551### error.isCanceled

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 552why, one step back
552

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 553why, one step back
553_Type:_ `boolean`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 554–558why, one step back
554
555Whether the subprocess was canceled using the [`cancelSignal`](#optionscancelsignal) option.556557[More info.](termination.md#canceling)558

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 559why, one step back
559### error.isMaxBuffer

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 560why, one step back
560

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 561why, one step back
561_Type:_ `boolean`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 562–566why, one step back
562
563Whether the subprocess failed because its output was larger than the [`maxBuffer`](#optionsmaxbuffer) option.564565[More info.](output.md#big-output)566

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 567why, one step back
567### error.isTerminated

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 568why, one step back
568

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 569why, one step back
569_Type:_ `boolean`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 570–576why, one step back
570
571Whether the subprocess was terminated by a [signal](termination.md#signal-termination) (like [`SIGTERM`](termination.md#sigterm)) sent by either:572- The current process.573- [Another process](termination.md#inter-process-termination). This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).574575[More info.](termination.md#signal-name-and-description)576

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 577why, one step back
577### error.exitCode

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 578why, one step back
578

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 579why, one step back
579_Type:_ `number | undefined`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 580–582why, one step back
580
581The numeric [exit code](https://en.wikipedia.org/wiki/Exit_status) of the subprocess that was run.582

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 583why, one step back
583This is `undefined` when the subprocess could not be spawned or was terminated by a [signal](#errorsignal).

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 584–586why, one step back
584
585[More info.](errors.md#exit-code)586

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 587why, one step back
587### error.signal

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 588why, one step back
588

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 589why, one step back
589_Type:_ `string | undefined`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 590–598why, one step back
590
591The name of the [signal](termination.md#signal-termination) (like [`SIGTERM`](termination.md#sigterm)) that terminated the subprocess, sent by either:592- The current process.593- [Another process](termination.md#inter-process-termination). This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).594595If a signal terminated the subprocess, this property is defined and included in the [error message](#errormessage). Otherwise it is `undefined`.596597[More info.](termination.md#signal-name-and-description)598

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 599why, one step back
599### error.signalDescription

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 600why, one step back
600

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 601why, one step back
601_Type:_ `string | undefined`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 602–610why, one step back
602
603A human-friendly description of the [signal](termination.md#signal-termination) that was used to terminate the subprocess.604605If a signal terminated the subprocess, this property is defined and included in the error message. Otherwise it is `undefined`. It is also `undefined` when the signal is very uncommon which should seldomly happen.606607[More info.](termination.md#signal-name-and-description)608609## Options610

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

line 611why, one step back
611_TypeScript:_ [`Options`](typescript.md) or [`SyncOptions`](typescript.md\

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 612why, one step back
612_Type:_ `object`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 613–619why, one step back
613
614This lists all options for [`execa()`](#execafile-arguments-options) and the [other methods](#methods).615616The following options [can specify different values](output.md#stdoutstderr-specific-options) for [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr): [`verbose`](#optionsverbose), [`lines`](#optionslines), [`stripFinalNewline`](#optionsstripfinalnewline), [`buffer`](#optionsbuffer), [`maxBuffer`](#optionsmaxbuffer).617618### options.preferLocal619

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 620–621why, one step back
620_Type:_ `boolean`\
621_Default:_ `true` with [`$`](#file-arguments-options), `false` otherwise

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 622–628why, one step back
622
623Prefer locally installed binaries when looking for a binary to execute.624625[More info.](environment.md#local-binaries)626627### options.localDir628

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 629–630why, one step back
629_Type:_ `string | URL`\
630_Default:_ [`cwd`](#optionscwd) option

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 631–637why, one step back
631
632Preferred path to find locally installed binaries, when using the [`preferLocal`](#optionspreferlocal) option.633634[More info.](environment.md#local-binaries)635636### options.node637

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 638–639why, one step back
638_Type:_ `boolean`\
639_Default:_ `true` with [`execaNode()`](#execanodescriptpath-arguments-options), `false` otherwise

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 640–642why, one step back
640
641If `true`, runs with Node.js. The first argument must be a Node.js file.642

Improve the documentation of the `node`/`nodePath`/`nodeOptions` options (#1011)ehmickybefore adoption4878db5

lines 643–644why, one step back
643The subprocess inherits the current Node.js [CLI flags](https://nodejs.org/api/cli.html#options) and version. This can be overridden using the [`nodeOptions`](#optionsnodeoptions) and [`nodePath`](#optionsnodepath) options.
644

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 645–648why, one step back
645[More info.](node.md)
646647### options.nodeOptions648

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 649why, one step back
649_Type:_ `string[]`\

Improve the documentation of the `node`/`nodePath`/`nodeOptions` options (#1011)ehmickybefore adoption4878db5

line 650why, one step back
650_Default:_ [`process.execArgv`](https://nodejs.org/api/process.html#process_process_execargv) (current Node.js CLI flags)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 651–659why, one step back
651
652List of [CLI flags](https://nodejs.org/api/cli.html#cli_options) passed to the [Node.js executable](#optionsnodepath).653654Requires the [`node`](#optionsnode) option to be `true`.655656[More info.](node.md#nodejs-cli-flags)657658### options.nodePath659

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 660–661why, one step back
660_Type:_ `string | URL`\
661_Default:_ [`process.execPath`](https://nodejs.org/api/process.html#process_process_execpath) (current Node.js executable)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 662–670why, one step back
662
663Path to the Node.js executable.664665Requires the [`node`](#optionsnode) option to be `true`.666667[More info.](node.md#nodejs-version)668669### options.shell670

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 671–672why, one step back
671_Type:_ `boolean | string | URL`\
672_Default:_ `false`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 673–683why, one step back
673
674If `true`, runs the command inside of a [shell](https://en.wikipedia.org/wiki/Shell_(computing)).675676Uses [`/bin/sh`](https://en.wikipedia.org/wiki/Unix_shell) on UNIX and [`cmd.exe`](https://en.wikipedia.org/wiki/Cmd.exe) on Windows. A different shell can be specified as a string. The shell should understand the `-c` switch on UNIX or `/d /s /c` on Windows.677678We [recommend against](shell.md#avoiding-shells) using this option.679680[More info.](shell.md)681682### options.cwd683

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 684–685why, one step back
684_Type:_ `string | URL`\
685_Default:_ `process.cwd()`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 686–694why, one step back
686
687Current [working directory](https://en.wikipedia.org/wiki/Working_directory) of the subprocess.688689This is also used to resolve the [`nodePath`](#optionsnodepath) option when it is a relative path.690691[More info.](environment.md#current-directory)692693### options.env694

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 695–696why, one step back
695_Type:_ `object`\
696_Default:_ [`process.env`](https://nodejs.org/api/process.html#processenv)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 697–705why, one step back
697
698[Environment variables](https://en.wikipedia.org/wiki/Environment_variable).699700Unless the [`extendEnv`](#optionsextendenv) option is `false`, the subprocess also uses the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).701702[More info.](input.md#environment-variables)703704### options.extendEnv705

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 706–707why, one step back
706_Type:_ `boolean`\
707_Default:_ `true`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 708–715why, one step back
708
709If `true`, the subprocess uses both the [`env`](#optionsenv) option and the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).710If `false`, only the `env` option is used, not `process.env`.711712[More info.](input.md#environment-variables)713714### options.input715

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 716why, one step back
716_Type:_ `string | Uint8Array | stream.Readable`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 717–725why, one step back
717
718Write some input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).719720See also the [`inputFile`](#optionsinputfile) and [`stdin`](#optionsstdin) options.721722[More info.](input.md#string-input)723724### options.inputFile725

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 726why, one step back
726_Type:_ `string | URL`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 727–735why, one step back
727
728Use a file as input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).729730See also the [`input`](#optionsinput) and [`stdin`](#optionsstdin) options.731732[More info.](input.md#file-input)733734### options.stdin735

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

line 736why, one step back
736_TypeScript:_ [`StdinOption`](typescript.md) or [`StdinSyncOption`](typescript.md)\

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 737–738why, one step back
737_Type:_ `string | number | stream.Readable | ReadableStream | TransformStream | URL | {file: string} | Uint8Array | Iterable<string | Uint8Array | unknown> | AsyncIterable<string | Uint8Array | unknown> | GeneratorFunction<string | Uint8Array | unknown> | AsyncGeneratorFunction<string | Uint8Array | unknown> | {transform: GeneratorFunction | AsyncGeneratorFunction | Duplex | TransformStream}` (or a tuple of those types)\
738_Default:_ `'inherit'` with [`$`](#file-arguments-options), `'pipe'` otherwise

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 739–747why, one step back
739
740How to setup the subprocess' [standard input](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)). This can be [`'pipe'`](streams.md#manual-streaming), [`'overlapped'`](windows.md#asynchronous-io), [`'ignore`](input.md#ignore-input), [`'inherit'`](input.md#terminal-input), a [file descriptor integer](input.md#terminal-input), a [Node.js `Readable` stream](streams.md#input), a web [`ReadableStream`](streams.md#web-streams), a [`{ file: 'path' }` object](input.md#file-input), a [file URL](input.md#file-input), an [`Iterable`](streams.md#iterables-as-input) (including an [array of strings](input.md#string-input)), an [`AsyncIterable`](streams.md#iterables-as-input), an [`Uint8Array`](binary.md#binary-input), a [generator function](transform.md), a [`Duplex`](transform.md#duplextransform-streams) or a web [`TransformStream`](transform.md#duplextransform-streams).741742This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.743744More info on [available values](input.md), [streaming](streams.md) and [transforms](transform.md).745746### options.stdout747

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

line 748why, one step back
748_TypeScript:_ [`StdoutStderrOption`](typescript.md) or [`StdoutStderrSyncOption`](typescript.md)\

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 749–750why, one step back
749_Type:_ `string | number | stream.Writable | WritableStream | TransformStream | URL | {file: string} | GeneratorFunction<string | Uint8Array | unknown> | AsyncGeneratorFunction<string | Uint8Array | unknown> | {transform: GeneratorFunction | AsyncGeneratorFunction | Duplex | TransformStream}` (or a tuple of those types)\
750_Default:_ `pipe`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 751–759why, one step back
751
752How to setup the subprocess' [standard output](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)). This can be [`'pipe'`](output.md#stdout-and-stderr), [`'overlapped'`](windows.md#asynchronous-io), [`'ignore`](output.md#ignore-output), [`'inherit'`](output.md#terminal-output), a [file descriptor integer](output.md#terminal-output), a [Node.js `Writable` stream](streams.md#output), a web [`WritableStream`](streams.md#web-streams), a [`{ file: 'path' }` object](output.md#file-output), a [file URL](output.md#file-output), a [generator function](transform.md), a [`Duplex`](transform.md#duplextransform-streams) or a web [`TransformStream`](transform.md#duplextransform-streams).753754This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.755756More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).757758### options.stderr759

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

line 760why, one step back
760_TypeScript:_ [`StdoutStderrOption`](typescript.md) or [`StdoutStderrSyncOption`](typescript.md)\

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 761–762why, one step back
761_Type:_ `string | number | stream.Writable | WritableStream | TransformStream | URL | {file: string} | GeneratorFunction<string | Uint8Array | unknown> | AsyncGeneratorFunction<string | Uint8Array | unknown> | {transform: GeneratorFunction | AsyncGeneratorFunction | Duplex | TransformStream}` (or a tuple of those types)\
762_Default:_ `pipe`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 763–771why, one step back
763
764How to setup the subprocess' [standard error](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)). This can be [`'pipe'`](output.md#stdout-and-stderr), [`'overlapped'`](windows.md#asynchronous-io), [`'ignore`](output.md#ignore-output), [`'inherit'`](output.md#terminal-output), a [file descriptor integer](output.md#terminal-output), a [Node.js `Writable` stream](streams.md#output), a web [`WritableStream`](streams.md#web-streams), a [`{ file: 'path' }` object](output.md#file-output), a [file URL](output.md#file-output), a [generator function](transform.md), a [`Duplex`](transform.md#duplextransform-streams) or a web [`TransformStream`](transform.md#duplextransform-streams).765766This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.767768More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).769770### options.stdio771

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

line 772why, one step back
772_TypeScript:_ [`Options['stdio']`](typescript.md) or [`SyncOptions['stdio']`](typescript.md)\

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 773–774why, one step back
773_Type:_ `string | Array<string | number | stream.Readable | stream.Writable | ReadableStream | WritableStream | TransformStream | URL | {file: string} | Uint8Array | Iterable<string> | Iterable<Uint8Array> | Iterable<unknown> | AsyncIterable<string | Uint8Array | unknown> | GeneratorFunction<string | Uint8Array | unknown> | AsyncGeneratorFunction<string | Uint8Array | unknown> | {transform: GeneratorFunction | AsyncGeneratorFunction | Duplex | TransformStream}>` (or a tuple of those types)\
774_Default:_ `pipe`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 775–785why, one step back
775
776Like the [`stdin`](#optionsstdin), [`stdout`](#optionsstdout) and [`stderr`](#optionsstderr) options but for all [file descriptors](https://en.wikipedia.org/wiki/File_descriptor) at once. For example, `{stdio: ['ignore', 'pipe', 'pipe']}` is the same as `{stdin: 'ignore', stdout: 'pipe', stderr: 'pipe'}`.777778A single string can be used [as a shortcut](output.md#shortcut).779780The array can have more than 3 items, to create [additional file descriptors](output.md#additional-file-descriptors) beyond [`stdin`](#optionsstdin)/[`stdout`](#optionsstdout)/[`stderr`](#optionsstderr).781782More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).783784### options.all785

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 786–787why, one step back
786_Type:_ `boolean`\
787_Default:_ `false`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 788–794why, one step back
788
789Add a [`subprocess.all`](#subprocessall) stream and a [`result.all`](#resultall) property.790791[More info.](output.md#interleaved-output)792793### options.encoding794

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 795–796why, one step back
795_Type:_ `'utf8' | 'utf16le' | 'buffer' | 'hex' | 'base64' | 'base64url' | 'latin1' | 'ascii'`\
796_Default:_ `'utf8'`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 797–809why, one step back
797
798If the subprocess outputs text, specifies its character encoding, either [`'utf8'`](https://en.wikipedia.org/wiki/UTF-8) or [`'utf16le'`](https://en.wikipedia.org/wiki/UTF-16).799800If it outputs binary data instead, this should be either:801- `'buffer'`: returns the binary output as an [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).802- [`'hex'`](https://en.wikipedia.org/wiki/Hexadecimal), [`'base64'`](https://en.wikipedia.org/wiki/Base64), [`'base64url'`](https://en.wikipedia.org/wiki/Base64#URL_applications), [`'latin1'`](https://nodejs.org/api/buffer.html#buffers-and-character-encodings) or [`'ascii'`](https://nodejs.org/api/buffer.html#buffers-and-character-encodings): encodes the binary output as a string.803804The output is available with [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr) and [`result.stdio`](#resultstdio).805806[More info.](binary.md)807808### options.lines809

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 810–811why, one step back
810_Type:_ `boolean`\
811_Default:_ `false`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 812–822why, one step back
812
813Set [`result.stdout`](#resultstdout), [`result.stderr`](#resultstdout), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) as arrays of strings, splitting the subprocess' output into lines.814815This cannot be used if the [`encoding`](#optionsencoding) option is [binary](binary.md#binary-output).816817By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).818819[More info.](lines.md#simple-splitting)820821### options.stripFinalNewline822

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 823–824why, one step back
823_Type:_ `boolean`\
824_Default:_ `true`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 825–835why, one step back
825
826Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.827828If the [`lines`](#optionslines) option is true, this applies to each output line instead.829830By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).831832[More info.](lines.md#newlines)833834### options.maxBuffer835

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 836–837why, one step back
836_Type:_ `number`\
837_Default:_ `100_000_000`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 838–846why, one step back
838
839Largest amount of data allowed on [`stdout`](#resultstdout), [`stderr`](#resultstderr) and [`stdio`](#resultstdio).840841By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).842843[More info.](output.md#big-output)844845### options.buffer846

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 847–848why, one step back
847_Type:_ `boolean`\
848_Default:_ `true`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 849–857why, one step back
849
850When `buffer` is `false`, the [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) properties are not set.851852By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).853854[More info.](output.md#low-memory)855856### options.ipc857

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 858–859why, one step back
858_Type:_ `boolean`\
859_Default:_ `true` if the [`node`](#optionsnode) option is enabled, `false` otherwise

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 860–866why, one step back
860
861Enables exchanging messages with the subprocess using [`subprocess.send(message)`](#subprocesssendmessage) and [`subprocess.on('message', (message) => {})`](#subprocessonmessage-message--void).862863[More info.](ipc.md)864865### options.serialization866

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 867–868why, one step back
867_Type:_ `'json' | 'advanced'`\
868_Default:_ `'advanced'`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 869–875why, one step back
869
870Specify the kind of serialization used for sending messages between subprocesses when using the [`ipc`](#optionsipc) option.871872[More info.](ipc.md#message-type)873874### options.verbose875

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 876–877why, one step back
876_Type:_ `'none' | 'short' | 'full'`\
877_Default:_ `'none'`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 878–888why, one step back
878
879If `verbose` is `'short'`, prints the command on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)): its file, arguments, duration and (if it failed) error message.880881If `verbose` is `'full'`, the command's [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) and `stderr` are also printed.882883By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).884885[More info.](debugging.md#verbose-mode)886887### options.reject888

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 889–890why, one step back
889_Type:_ `boolean`\
890_Default:_ `true`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

line 891why, one step back
891

Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b

line 892why, one step back
892Setting this to `false` resolves the [result's promise](#return-value) with the [error](#execaerror) instead of rejecting it.

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 893–897why, one step back
893
894[More info.](errors.md#preventing-exceptions)895896### options.timeout897

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 898–899why, one step back
898_Type:_ `number`\
899_Default:_ `0`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 900–902why, one step back
900
901If `timeout` is greater than `0`, the subprocess will be [terminated](#optionskillsignal) if it runs for longer than that amount of milliseconds.902

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 903why, one step back
903On timeout, [`result.timedOut`](#errortimedout) becomes `true`.

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 904–908why, one step back
904
905[More info.](termination.md#timeout)906907### options.cancelSignal908

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 909why, one step back
909_Type:_ [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 910–912why, one step back
910
911You can abort the subprocess using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).912

Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec

line 913why, one step back
913When `AbortController.abort()` is called, [`result.isCanceled`](#erroriscanceled) becomes `true`.

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 914–918why, one step back
914
915[More info.](termination.md#canceling)916917### options.forceKillAfterDelay918

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 919–920why, one step back
919_Type:_ `number | false`\
920_Default:_ `5000`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 921–927why, one step back
921
922If the subprocess is terminated but does not exit, forcefully exit it by sending [`SIGKILL`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL).923924[More info.](termination.md#forceful-termination)925926### options.killSignal927

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 928–929why, one step back
928_Type:_ `string | number`\
929_Default:_ `'SIGTERM'`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 930–938why, one step back
930
931Default [signal](https://en.wikipedia.org/wiki/Signal_(IPC)) used to terminate the subprocess.932933This can be either a name (like [`'SIGTERM'`](termination.md#sigterm)) or a number (like `9`).934935[More info.](termination.md#default-signal)936937### options.detached938

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 939–940why, one step back
939_Type:_ `boolean`\
940_Default:_ `false`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 941–947why, one step back
941
942Run the subprocess independently from the current process.943944[More info.](environment.md#background-subprocess)945946### options.cleanup947

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 948–949why, one step back
948_Type:_ `boolean`\
949_Default:_ `true`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 950–956why, one step back
950
951Kill the subprocess when the current process exits.952953[More info.](termination.md#current-process-exit)954955### options.uid956

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 957–958why, one step back
957_Type:_ `number`\
958_Default:_ current user identifier

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 959–965why, one step back
959
960Sets the [user identifier](https://en.wikipedia.org/wiki/User_identifier) of the subprocess.961962[More info.](windows.md#uid-and-gid)963964### options.gid965

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 966–967why, one step back
966_Type:_ `number`\
967_Default:_ current group identifier

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 968–974why, one step back
968
969Sets the [group identifier](https://en.wikipedia.org/wiki/Group_identifier) of the subprocess.970971[More info.](windows.md#uid-and-gid)972973### options.argv0974

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 975–976why, one step back
975_Type:_ `string`\
976_Default:_ file being executed

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 977–981why, one step back
977
978Value of [`argv[0]`](https://nodejs.org/api/process.html#processargv0) sent to the subprocess.979980### options.windowsHide981

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 982–983why, one step back
982_Type:_ `boolean`\
983_Default:_ `true`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 984–990why, one step back
984
985On Windows, do not create a new console window.986987[More info.](windows.md#console-window)988989### options.windowsVerbatimArguments990

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 991–992why, one step back
991_Type:_ `boolean`\
992_Default:_ `true` if the [`shell`](#optionsshell) option is `true`, `false` otherwise

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 993–1007why, one step back
993
994If `false`, escapes the command arguments on Windows.995996[More info.](windows.md#cmdexe-escaping)997998## Transform options9991000A transform or an [array of transforms](transform.md#combining) can be passed to the [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) or [`stdio`](#optionsstdio) option.10011002A transform is either a [generator function](#transformoptionstransform) or a plain object with the following members.10031004[More info.](transform.md)10051006### transformOptions.transform1007

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 1008why, one step back
1008_Type:_ `GeneratorFunction<string | Uint8Array | unknown>` | `AsyncGeneratorFunction<string | Uint8Array | unknown>`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 1009–1015why, one step back
1009
1010Map or [filter](transform.md#filtering) the [input](input.md) or [output](output.md) of the subprocess.10111012More info [here](transform.md#summary) and [there](transform.md#sharing-state).10131014### transformOptions.final1015

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

line 1016why, one step back
1016_Type:_ `GeneratorFunction<string | Uint8Array | unknown>` | `AsyncGeneratorFunction<string | Uint8Array | unknown>`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 1017–1023why, one step back
1017
1018Create additional lines after the last one.10191020[More info.](transform.md#finalizing)10211022### transformOptions.binary1023

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 1024–1025why, one step back
1024_Type:_ `boolean`\
1025_Default:_ `false`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 1026–1032why, one step back
1026
1027If `true`, iterate over arbitrary chunks of `Uint8Array`s instead of line `string`s.10281029[More info.](binary.md#transforms)10301031### transformOptions.preserveNewlines1032

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 1033–1034why, one step back
1033_Type:_ `boolean`\
1034_Default:_ `false`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 1035–1041why, one step back
1035
1036If `true`, keep newlines in each `line` argument. Also, this allows multiple `yield`s to produces a single line.10371038[More info.](lines.md#transforms)10391040### transformOptions.objectMode1041

Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f

lines 1042–1043why, one step back
1042_Type:_ `boolean`\
1043_Default:_ `false`

Move API reference to its own page (#996)ehmickybefore adoption7cde496

lines 1044–1052why, one step back
1044
1045If `true`, allow [`transformOptions.transform`](#transformoptionstransform) and [`transformOptions.final`](#transformoptionsfinal) to return any type, not just `string` or `Uint8Array`.10461047[More info.](transform.md#object-mode)10481049<hr>10501051[**Previous**: 🔍 Differences with Bash and zx](bash.md)\1052[**Top**: Table of contents](../readme.md#documentation)