api.md
This file
Path
docs/api.md
1,047 lines · 41.6 KiB · Markdown
Last changed by
Add `parseCommandString()` (#1054)ehmickybefore adoptionb9474c3
History of this fileTake it
Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1–17why, one step back1<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 back18_Returns_: [`ResultPromise`](#return-value)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 19–28why, one step back1920Executes 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 back29_Returns_: [`ResultPromise`](#return-value)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 30–46why, one step back3031Executes 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\`46Rename some types (#1009)ehmickybefore adoption2ef9186
line 47why, one step back47_Returns_: [`SyncResult`](#return-value)Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
line 48why, one step back48Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 49–59why, one step back49Same 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 back60_Returns_: [`ResultPromise`](#return-value)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 61–74why, one step back6162Same 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 back75_Returns_: [`ResultPromise`](#return-value)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 76–85why, one step back7677Same 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)85Add `parseCommandString()` (#1054)ehmickybefore adoptionb9474c3
line 86why, one step back86### parseCommandString(command)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 87–88why, one step back8788`command`: `string`\Add `parseCommandString()` (#1054)ehmickybefore adoptionb9474c3
line 89why, one step back89_Returns_: `string[]`Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 90why, one step back90Add `parseCommandString()` (#1054)ehmickybefore adoptionb9474c3
line 91why, one step back91Split a `command` string into an array. For example, `'npm run build'` returns `['npm', 'run', 'build']` and `'argument otherArgument'` returns `['argument', 'otherArgument']`.Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 92–94why, one step back9293[More info.](escaping.md#user-defined-input)94Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
line 95why, one step back95## Return valueMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 96why, one step back96Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
lines 97–98why, one step back97_TypeScript:_ [`ResultPromise`](typescript.md)\98_Type:_ `Promise<object> | Subprocess`Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
line 99why, one step back99Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 100why, one step back100The return value of all [asynchronous methods](#methods) is both:Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
lines 101–102why, one step back101- the [subprocess](#subprocess).102- 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 103–105why, one step back103104[More info.](execution.md#subprocess)105Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
lines 106–107why, one step back106## Subprocess107Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
line 108why, one step back108_TypeScript:_ [`Subprocess`](typescript.md)Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
lines 109–111why, one step back109110[`child_process` instance](https://nodejs.org/api/child_process.html#child_process_class_childprocess) with the following methods and properties.111Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 112–154why, one step back112### subprocess\[Symbol.asyncIterator\]()113114_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)115116Subprocesses are [async iterables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator). They iterate over each output line.117118[More info.](lines.md#progressive-splitting)119120### subprocess.iterable(readableOptions?)121122`readableOptions`: [`ReadableOptions`](#readableoptions)\123_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)124125Same as [`subprocess[Symbol.asyncIterator]`](#subprocesssymbolasynciterator) except [options](#readableoptions) can be provided.126127[More info.](lines.md#progressive-splitting)128129### subprocess.pipe(file, arguments?, options?)130131`file`: `string | URL`\132`arguments`: `string[]`\133`options`: [`Options`](#options) and [`PipeOptions`](#pipeoptions)\134_Returns_: [`Promise<Result>`](#result)135136[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.137138This 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.139140[More info.](pipe.md#array-syntax)141142### subprocess.pipe\`command\`143### subprocess.pipe(options)\`command\`144145`command`: `string`\146`options`: [`Options`](#options) and [`PipeOptions`](#pipeoptions)\147_Returns_: [`Promise<Result>`](#result)148149Like [`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).150151[More info.](pipe.md#template-string-syntax)152153### subprocess.pipe(secondSubprocess, pipeOptions?)154Rename some types (#1009)ehmickybefore adoption2ef9186
line 155why, one step back155`secondSubprocess`: [`ResultPromise`](#return-value)\Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 156–158why, one step back156`pipeOptions`: [`PipeOptions`](#pipeoptions)\157_Returns_: [`Promise<Result>`](#result)158Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
line 159why, one step back159Like [`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 160–164why, one step back160161[More info.](pipe.md#advanced-syntax)162163#### pipeOptions164Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 165why, one step back165_Type:_ `object`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 166–168why, one step back166167#### pipeOptions.from168Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 169–170why, one step back169_Type:_ `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\170_Default:_ `"stdout"`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 171–179why, one step back171172Which stream to pipe from the source subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.173174`"all"` pipes both [`stdout`](#subprocessstdout) and [`stderr`](#subprocessstderr). This requires the [`all`](#optionsall) option to be `true`.175176[More info.](pipe.md#source-file-descriptor)177178#### pipeOptions.to179Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 180–181why, one step back180_Type:_ `"stdin" | "fd3" | "fd4" | ...`\181_Default:_ `"stdin"`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 182–188why, one step back182183Which [stream](#subprocessstdin) to pipe to the destination subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.184185[More info.](pipe.md#destination-file-descriptor)186187#### pipeOptions.unpipeSignal188Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 189why, one step back189_Type:_ [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 190–201why, one step back190191Unpipe the subprocess when the signal aborts.192193[More info.](pipe.md#unpipe)194195### subprocess.kill(signal, error?)196### subprocess.kill(error?)197198`signal`: `string | number`\199`error`: `Error`\200_Returns_: `boolean`201Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 202why, one step back202Sends 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 203–211why, one step back203204This returns `false` when the signal could not be sent, for example when the subprocess has already exited.205206When 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).207208[More info.](termination.md)209210### subprocess.pid211Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 212why, one step back212_Type:_ `number | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 213–246why, one step back213214Process identifier ([PID](https://en.wikipedia.org/wiki/Process_identifier)).215216This is `undefined` if the subprocess failed to spawn.217218[More info.](termination.md#inter-process-termination)219220### subprocess.send(message)221222`message`: `unknown`\223_Returns_: `boolean`224225Send a `message` to the subprocess. The type of `message` depends on the [`serialization`](#optionsserialization) option.226The subprocess receives it as a [`message` event](https://nodejs.org/api/process.html#event-message).227228This returns `true` on success.229230This requires the [`ipc`](#optionsipc) option to be `true`.231232[More info.](ipc.md#exchanging-messages)233234### subprocess.on('message', (message) => void)235236`message`: `unknown`237238Receives a `message` from the subprocess. The type of `message` depends on the [`serialization`](#optionsserialization) option.239The subprocess sends it using [`process.send(message)`](https://nodejs.org/api/process.html#processsendmessage-sendhandle-options-callback).240241This requires the [`ipc`](#optionsipc) option to be `true`.242243[More info.](ipc.md#exchanging-messages)244245### subprocess.stdin246Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 247why, one step back247_Type:_ [`Writable | null`](https://nodejs.org/api/stream.html#class-streamwritable)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 248–256why, one step back248249The subprocess [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)) as a stream.250251This 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).252253[More info.](streams.md#manual-streaming)254255### subprocess.stdout256Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 257why, one step back257_Type:_ [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 258–266why, one step back258259The subprocess [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) as a stream.260261This 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`.262263[More info.](streams.md#manual-streaming)264265### subprocess.stderr266Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 267why, one step back267_Type:_ [`Readable | null`](https://nodejs.org/api/stream.html#class-streamreadable)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 268–276why, one step back268269The subprocess [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)) as a stream.270271This 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`.272273[More info.](streams.md#manual-streaming)274275### subprocess.all276Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 277why, one step back277_Type:_ [`Readable | undefined`](https://nodejs.org/api/stream.html#class-streamreadable)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 278–288why, one step back278279Stream combining/interleaving [`subprocess.stdout`](#subprocessstdout) and [`subprocess.stderr`](#subprocessstderr).280281This requires the [`all`](#optionsall) option to be `true`.282283This 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`.284285More info on [interleaving](output.md#interleaved-output) and [streaming](streams.md#manual-streaming).286287### subprocess.stdio288Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 289why, one step back289_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 290–307why, one step back290291The subprocess [`stdin`](#subprocessstdin), [`stdout`](#subprocessstdout), [`stderr`](#subprocessstderr) and [other files descriptors](#optionsstdio) as an array of streams.292293Each 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`.294295[More info.](streams.md#manual-streaming)296297### subprocess.readable(readableOptions?)298299`readableOptions`: [`ReadableOptions`](#readableoptions)\300_Returns_: [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable) Node.js stream301302Converts the subprocess to a readable stream.303304[More info.](streams.md#converting-a-subprocess-to-a-stream)305306#### readableOptions307Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 308why, one step back308_Type:_ `object`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 309–311why, one step back309310#### readableOptions.from311Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 312–313why, one step back312_Type:_ `"stdout" | "stderr" | "all" | "fd3" | "fd4" | ...`\313_Default:_ `"stdout"`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 314–322why, one step back314315Which stream to read from the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.316317`"all"` reads both [`stdout`](#subprocessstdout) and [`stderr`](#subprocessstderr). This requires the [`all`](#optionsall) option to be `true`.318319[More info.](streams.md#different-file-descriptor)320321#### readableOptions.binary322Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 323–324why, one step back323_Type:_ `boolean`\324_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 325–335why, one step back325326If `false`, iterates over lines. Each line is a string.327328If `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)).329330This is always `true` when the [`encoding`](#optionsencoding) option is binary.331332More info for [iterables](binary.md#iterable) and [streams](binary.md#streams).333334#### readableOptions.preserveNewlines335Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 336–337why, one step back336_Type:_ `boolean`\337_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 338–353why, one step back338339If both this option and the [`binary`](#readableoptionsbinary) option is `false`, [newlines](https://en.wikipedia.org/wiki/Newline) are stripped from each line.340341[More info.](lines.md#iterable)342343### subprocess.writable(writableOptions?)344345`writableOptions`: [`WritableOptions`](#writableoptions)\346_Returns_: [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable) Node.js stream347348Converts the subprocess to a writable stream.349350[More info.](streams.md#converting-a-subprocess-to-a-stream)351352#### writableOptions353Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 354why, one step back354_Type:_ `object`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 355–357why, one step back355356#### writableOptions.to357Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 358–359why, one step back358_Type:_ `"stdin" | "fd3" | "fd4" | ...`\359_Default:_ `"stdin"`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 360–375why, one step back360361Which [stream](#subprocessstdin) to write to the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.362363[More info.](streams.md#different-file-descriptor)364365### subprocess.duplex(duplexOptions?)366367`duplexOptions`: [`ReadableOptions | WritableOptions`](#readableoptions)\368_Returns_: [`Duplex`](https://nodejs.org/api/stream.html#class-streamduplex) Node.js stream369370Converts the subprocess to a duplex stream.371372[More info.](streams.md#converting-a-subprocess-to-a-stream)373374## Result375Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
line 376why, one step back376_TypeScript:_ [`Result`](typescript.md) or [`SyncResult`](typescript.md\Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 377why, one step back377_Type:_ `object`Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 378why, one step back378Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 379why, one step back379[Result](execution.md#result) of a subprocess successful execution.Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 380–384why, one step back380381When the subprocess [fails](errors.md#subprocess-failure), it is rejected with an [`ExecaError`](#execaerror) instead.382383### result.stdout384Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 385why, one step back385_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 386–396why, one step back386387The output of the subprocess on [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)).388389This 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`.390391This 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).392393[More info.](output.md#stdout-and-stderr)394395### result.stderr396Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 397why, one step back397_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 398–408why, one step back398399The output of the subprocess on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)).400401This 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`.402403This 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).404405[More info.](output.md#stdout-and-stderr)406407### result.all408Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 409why, one step back409_Type:_ `string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 410–422why, one step back410411The output of the subprocess with [`result.stdout`](#resultstdout) and [`result.stderr`](#resultstderr) interleaved.412413This requires the [`all`](#optionsall) option to be `true`.414415This 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`.416417This 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).418419[More info.](output.md#interleaved-output)420421### result.stdio422Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 423why, one step back423_Type:_ `Array<string | Uint8Array | string[] | Uint8Array[] | unknown[] | undefined>`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 424–434why, one step back424425The output of the subprocess on [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) and [other file descriptors](#optionsstdio).426427Items 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`.428429Items are arrays when their corresponding `stdio` option is a [transform in object mode](transform.md#object-mode).430431[More info.](output.md#additional-file-descriptors)432433### result.pipedFrom434Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 435why, one step back435_Type:_ [`Array<Result | ExecaError>`](#result)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 436–444why, one step back436437[Results](#result) of the other subprocesses that were piped into this subprocess.438439This array is initially empty and is populated each time the [`subprocess.pipe()`](#subprocesspipefile-arguments-options) method resolves.440441[More info.](pipe.md#result)442443### result.command444Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 445why, one step back445_Type:_ `string`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 446–452why, one step back446447The file and [arguments](input.md#command-arguments) that were run.448449[More info.](debugging.md#command)450451### result.escapedCommand452Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 453why, one step back453_Type:_ `string`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 454–460why, one step back454455Same as [`command`](#resultcommand) but escaped.456457[More info.](debugging.md#command)458459### result.cwd460Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 461why, one step back461_Type:_ `string`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 462–468why, one step back462463The [current directory](#optionscwd) in which the command was run.464465[More info.](environment.md#current-directory)466467### result.durationMs468Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 469why, one step back469_Type:_ `number`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 470–476why, one step back470471Duration of the subprocess, in milliseconds.472473[More info.](debugging.md#duration)474475### result.failed476Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 477why, one step back477_Type:_ `boolean`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 478–480why, one step back478479Whether the subprocess failed to run.480Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 481–482why, one step back481When this is `true`, the result is an [`ExecaError`](#execaerror) instance with additional error-related properties.482Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 483–484why, one step back483[More info.](errors.md#subprocess-failure)484Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 485–486why, one step back485## ExecaError486## ExecaSyncErrorMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 487why, one step back487Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 488why, one step back488_Type:_ `Error`Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 489–499why, one step back489490Result of a subprocess [failed execution](errors.md#subprocess-failure).491492This error is thrown as an exception. If the [`reject`](#optionsreject) option is false, it is returned instead.493494This has the same shape as [successful results](#result), with the following additional properties.495496[More info.](errors.md)497498### error.message499Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 500why, one step back500_Type:_ `string`Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 501–507why, one step back501502Error message when the subprocess [failed](errors.md#subprocess-failure) to run.503504[More info.](errors.md#error-message)505506### error.shortMessage507Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 508why, one step back508_Type:_ `string`Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 509–515why, one step back509510This is the same as [`error.message`](#errormessage) except it does not include the subprocess [output](output.md).511512[More info.](errors.md#error-message)513514### error.originalMessage515Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 516why, one step back516_Type:_ `string | undefined`Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 517–523why, one step back517518Original error message. This is the same as [`error.message`](#errormessage) excluding the subprocess [output](output.md) and some additional information added by Execa.519520[More info.](errors.md#error-message)521522### error.cause523Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 524why, one step back524_Type:_ `unknown | undefined`Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 525–533why, one step back525526Underlying error, if there is one. For example, this is set by [`subprocess.kill(error)`](#subprocesskillerror).527528This is usually an `Error` instance.529530[More info.](termination.md#error-message-and-stack-trace)531532### error.code533Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 534why, one step back534_Type:_ `string | undefined`Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
lines 535–539why, one step back535536Node.js-specific [error code](https://nodejs.org/api/errors.html#errorcode), when available.537538### error.timedOut539Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 540why, one step back540_Type:_ `boolean`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 541–545why, one step back541542Whether the subprocess timed out due to the [`timeout`](#optionstimeout) option.543544[More info.](termination.md#timeout)545Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 546why, one step back546### error.isCanceledMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 547why, one step back547Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 548why, one step back548_Type:_ `boolean`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 549–553why, one step back549550Whether the subprocess was canceled using the [`cancelSignal`](#optionscancelsignal) option.551552[More info.](termination.md#canceling)553Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 554why, one step back554### error.isMaxBufferMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 555why, one step back555Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 556why, one step back556_Type:_ `boolean`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 557–561why, one step back557558Whether the subprocess failed because its output was larger than the [`maxBuffer`](#optionsmaxbuffer) option.559560[More info.](output.md#big-output)561Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 562why, one step back562### error.isTerminatedMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 563why, one step back563Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 564why, one step back564_Type:_ `boolean`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 565–571why, one step back565566Whether the subprocess was terminated by a [signal](termination.md#signal-termination) (like [`SIGTERM`](termination.md#sigterm)) sent by either:567- The current process.568- [Another process](termination.md#inter-process-termination). This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).569570[More info.](termination.md#signal-name-and-description)571Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 572why, one step back572### error.exitCodeMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 573why, one step back573Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 574why, one step back574_Type:_ `number | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 575–577why, one step back575576The numeric [exit code](https://en.wikipedia.org/wiki/Exit_status) of the subprocess that was run.577Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 578why, one step back578This 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 579–581why, one step back579580[More info.](errors.md#exit-code)581Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 582why, one step back582### error.signalMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 583why, one step back583Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 584why, one step back584_Type:_ `string | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 585–593why, one step back585586The name of the [signal](termination.md#signal-termination) (like [`SIGTERM`](termination.md#sigterm)) that terminated the subprocess, sent by either:587- The current process.588- [Another process](termination.md#inter-process-termination). This case is [not supported on Windows](https://nodejs.org/api/process.html#signal-events).589590If a signal terminated the subprocess, this property is defined and included in the [error message](#errormessage). Otherwise it is `undefined`.591592[More info.](termination.md#signal-name-and-description)593Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 594why, one step back594### error.signalDescriptionMove API reference to its own page (#996)ehmickybefore adoption7cde496
line 595why, one step back595Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 596why, one step back596_Type:_ `string | undefined`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 597–605why, one step back597598A human-friendly description of the [signal](termination.md#signal-termination) that was used to terminate the subprocess.599600If 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.601602[More info.](termination.md#signal-name-and-description)603604## Options605Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
line 606why, one step back606_TypeScript:_ [`Options`](typescript.md) or [`SyncOptions`](typescript.md\Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 607why, one step back607_Type:_ `object`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 608–614why, one step back608609This lists all options for [`execa()`](#execafile-arguments-options) and the [other methods](#methods).610611The 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).612613### options.preferLocal614Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 615–616why, one step back615_Type:_ `boolean`\616_Default:_ `true` with [`$`](#file-arguments-options), `false` otherwiseMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 617–623why, one step back617618Prefer locally installed binaries when looking for a binary to execute.619620[More info.](environment.md#local-binaries)621622### options.localDir623Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 624–625why, one step back624_Type:_ `string | URL`\625_Default:_ [`cwd`](#optionscwd) optionMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 626–632why, one step back626627Preferred path to find locally installed binaries, when using the [`preferLocal`](#optionspreferlocal) option.628629[More info.](environment.md#local-binaries)630631### options.node632Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 633–634why, one step back633_Type:_ `boolean`\634_Default:_ `true` with [`execaNode()`](#execanodescriptpath-arguments-options), `false` otherwiseMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 635–637why, one step back635636If `true`, runs with Node.js. The first argument must be a Node.js file.637Improve the documentation of the `node`/`nodePath`/`nodeOptions` options (#1011)ehmickybefore adoption4878db5
lines 638–639why, one step back638The 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.639Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 640–643why, one step back640[More info.](node.md)641642### options.nodeOptions643Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 644why, one step back644_Type:_ `string[]`\Improve the documentation of the `node`/`nodePath`/`nodeOptions` options (#1011)ehmickybefore adoption4878db5
line 645why, one step back645_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 646–654why, one step back646647List of [CLI flags](https://nodejs.org/api/cli.html#cli_options) passed to the [Node.js executable](#optionsnodepath).648649Requires the [`node`](#optionsnode) option to be `true`.650651[More info.](node.md#nodejs-cli-flags)652653### options.nodePath654Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 655–656why, one step back655_Type:_ `string | URL`\656_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 657–665why, one step back657658Path to the Node.js executable.659660Requires the [`node`](#optionsnode) option to be `true`.661662[More info.](node.md#nodejs-version)663664### options.shell665Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 666–667why, one step back666_Type:_ `boolean | string | URL`\667_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 668–678why, one step back668669If `true`, runs the command inside of a [shell](https://en.wikipedia.org/wiki/Shell_(computing)).670671Uses [`/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.672673We [recommend against](shell.md#avoiding-shells) using this option.674675[More info.](shell.md)676677### options.cwd678Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 679–680why, one step back679_Type:_ `string | URL`\680_Default:_ `process.cwd()`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 681–689why, one step back681682Current [working directory](https://en.wikipedia.org/wiki/Working_directory) of the subprocess.683684This is also used to resolve the [`nodePath`](#optionsnodepath) option when it is a relative path.685686[More info.](environment.md#current-directory)687688### options.env689Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 690–691why, one step back690_Type:_ `object`\691_Default:_ [`process.env`](https://nodejs.org/api/process.html#processenv)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 692–700why, one step back692693[Environment variables](https://en.wikipedia.org/wiki/Environment_variable).694695Unless the [`extendEnv`](#optionsextendenv) option is `false`, the subprocess also uses the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).696697[More info.](input.md#environment-variables)698699### options.extendEnv700Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 701–702why, one step back701_Type:_ `boolean`\702_Default:_ `true`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 703–710why, one step back703704If `true`, the subprocess uses both the [`env`](#optionsenv) option and the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).705If `false`, only the `env` option is used, not `process.env`.706707[More info.](input.md#environment-variables)708709### options.input710Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 711why, one step back711_Type:_ `string | Uint8Array | stream.Readable`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 712–720why, one step back712713Write some input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).714715See also the [`inputFile`](#optionsinputfile) and [`stdin`](#optionsstdin) options.716717[More info.](input.md#string-input)718719### options.inputFile720Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 721why, one step back721_Type:_ `string | URL`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 722–730why, one step back722723Use a file as input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).724725See also the [`input`](#optionsinput) and [`stdin`](#optionsstdin) options.726727[More info.](input.md#file-input)728729### options.stdin730Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
line 731why, one step back731_TypeScript:_ [`StdinOption`](typescript.md) or [`StdinSyncOption`](typescript.md)\Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 732–733why, one step back732_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)\733_Default:_ `'inherit'` with [`$`](#file-arguments-options), `'pipe'` otherwiseMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 734–742why, one step back734735How 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).736737This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.738739More info on [available values](input.md), [streaming](streams.md) and [transforms](transform.md).740741### options.stdout742Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
line 743why, one step back743_TypeScript:_ [`StdoutStderrOption`](typescript.md) or [`StdoutStderrSyncOption`](typescript.md)\Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 744–745why, one step back744_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)\745_Default:_ `pipe`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 746–754why, one step back746747How 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).748749This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.750751More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).752753### options.stderr754Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
line 755why, one step back755_TypeScript:_ [`StdoutStderrOption`](typescript.md) or [`StdoutStderrSyncOption`](typescript.md)\Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 756–757why, one step back756_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)\757_Default:_ `pipe`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 758–766why, one step back758759How 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).760761This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.762763More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).764765### options.stdio766Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058
line 767why, one step back767_TypeScript:_ [`Options['stdio']`](typescript.md) or [`SyncOptions['stdio']`](typescript.md)\Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 768–769why, one step back768_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)\769_Default:_ `pipe`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 770–780why, one step back770771Like 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'}`.772773A single string can be used [as a shortcut](output.md#shortcut).774775The array can have more than 3 items, to create [additional file descriptors](output.md#additional-file-descriptors) beyond [`stdin`](#optionsstdin)/[`stdout`](#optionsstdout)/[`stderr`](#optionsstderr).776777More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).778779### options.all780Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 781–782why, one step back781_Type:_ `boolean`\782_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 783–789why, one step back783784Add a [`subprocess.all`](#subprocessall) stream and a [`result.all`](#resultall) property.785786[More info.](output.md#interleaved-output)787788### options.encoding789Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 790–791why, one step back790_Type:_ `'utf8' | 'utf16le' | 'buffer' | 'hex' | 'base64' | 'base64url' | 'latin1' | 'ascii'`\791_Default:_ `'utf8'`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 792–804why, one step back792793If 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).794795If it outputs binary data instead, this should be either:796- `'buffer'`: returns the binary output as an [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).797- [`'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.798799The output is available with [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr) and [`result.stdio`](#resultstdio).800801[More info.](binary.md)802803### options.lines804Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 805–806why, one step back805_Type:_ `boolean`\806_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 807–817why, one step back807808Set [`result.stdout`](#resultstdout), [`result.stderr`](#resultstdout), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) as arrays of strings, splitting the subprocess' output into lines.809810This cannot be used if the [`encoding`](#optionsencoding) option is [binary](binary.md#binary-output).811812By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).813814[More info.](lines.md#simple-splitting)815816### options.stripFinalNewline817Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 818–819why, one step back818_Type:_ `boolean`\819_Default:_ `true`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 820–830why, one step back820821Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.822823If the [`lines`](#optionslines) option is true, this applies to each output line instead.824825By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).826827[More info.](lines.md#newlines)828829### options.maxBuffer830Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 831–832why, one step back831_Type:_ `number`\832_Default:_ `100_000_000`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 833–841why, one step back833834Largest amount of data allowed on [`stdout`](#resultstdout), [`stderr`](#resultstderr) and [`stdio`](#resultstdio).835836By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).837838[More info.](output.md#big-output)839840### options.buffer841Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 842–843why, one step back842_Type:_ `boolean`\843_Default:_ `true`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 844–852why, one step back844845When `buffer` is `false`, the [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr), [`result.all`](#resultall) and [`result.stdio`](#resultstdio) properties are not set.846847By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).848849[More info.](output.md#low-memory)850851### options.ipc852Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 853–854why, one step back853_Type:_ `boolean`\854_Default:_ `true` if the [`node`](#optionsnode) option is enabled, `false` otherwiseMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 855–861why, one step back855856Enables exchanging messages with the subprocess using [`subprocess.send(message)`](#subprocesssendmessage) and [`subprocess.on('message', (message) => {})`](#subprocessonmessage-message--void).857858[More info.](ipc.md)859860### options.serialization861Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 862–863why, one step back862_Type:_ `'json' | 'advanced'`\863_Default:_ `'advanced'`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 864–870why, one step back864865Specify the kind of serialization used for sending messages between subprocesses when using the [`ipc`](#optionsipc) option.866867[More info.](ipc.md#message-type)868869### options.verbose870Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 871–872why, one step back871_Type:_ `'none' | 'short' | 'full'`\872_Default:_ `'none'`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 873–883why, one step back873874If `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.875876If `verbose` is `'full'`, the command's [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) and `stderr` are also printed.877878By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).879880[More info.](debugging.md#verbose-mode)881882### options.reject883Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 884–885why, one step back884_Type:_ `boolean`\885_Default:_ `true`Move API reference to its own page (#996)ehmickybefore adoption7cde496
line 886why, one step back886Fix the type of the return value (#1007)ehmickybefore adoption0a13f2b
line 887why, one step back887Setting 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 888–892why, one step back888889[More info.](errors.md#preventing-exceptions)890891### options.timeout892Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 893–894why, one step back893_Type:_ `number`\894_Default:_ `0`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 895–897why, one step back895896If `timeout` is greater than `0`, the subprocess will be [terminated](#optionskillsignal) if it runs for longer than that amount of milliseconds.897Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 898why, one step back898On timeout, [`result.timedOut`](#errortimedout) becomes `true`.Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 899–903why, one step back899900[More info.](termination.md#timeout)901902### options.cancelSignal903Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 904why, one step back904_Type:_ [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 905–907why, one step back905906You can abort the subprocess using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).907Improve documentation of `error.*` fields (#1006)ehmickybefore adoption4ee0dec
line 908why, one step back908When `AbortController.abort()` is called, [`result.isCanceled`](#erroriscanceled) becomes `true`.Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 909–913why, one step back909910[More info.](termination.md#canceling)911912### options.forceKillAfterDelay913Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 914–915why, one step back914_Type:_ `number | false`\915_Default:_ `5000`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 916–922why, one step back916917If the subprocess is terminated but does not exit, forcefully exit it by sending [`SIGKILL`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL).918919[More info.](termination.md#forceful-termination)920921### options.killSignal922Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 923–924why, one step back923_Type:_ `string | number`\924_Default:_ `'SIGTERM'`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 925–933why, one step back925926Default [signal](https://en.wikipedia.org/wiki/Signal_(IPC)) used to terminate the subprocess.927928This can be either a name (like [`'SIGTERM'`](termination.md#sigterm)) or a number (like `9`).929930[More info.](termination.md#default-signal)931932### options.detached933Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 934–935why, one step back934_Type:_ `boolean`\935_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 936–942why, one step back936937Run the subprocess independently from the current process.938939[More info.](environment.md#background-subprocess)940941### options.cleanup942Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 943–944why, one step back943_Type:_ `boolean`\944_Default:_ `true`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 945–951why, one step back945946Kill the subprocess when the current process exits.947948[More info.](termination.md#current-process-exit)949950### options.uid951Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 952–953why, one step back952_Type:_ `number`\953_Default:_ current user identifierMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 954–960why, one step back954955Sets the [user identifier](https://en.wikipedia.org/wiki/User_identifier) of the subprocess.956957[More info.](windows.md#uid-and-gid)958959### options.gid960Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 961–962why, one step back961_Type:_ `number`\962_Default:_ current group identifierMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 963–969why, one step back963964Sets the [group identifier](https://en.wikipedia.org/wiki/Group_identifier) of the subprocess.965966[More info.](windows.md#uid-and-gid)967968### options.argv0969Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 970–971why, one step back970_Type:_ `string`\971_Default:_ file being executedMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 972–976why, one step back972973Value of [`argv[0]`](https://nodejs.org/api/process.html#processargv0) sent to the subprocess.974975### options.windowsHide976Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 977–978why, one step back977_Type:_ `boolean`\978_Default:_ `true`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 979–985why, one step back979980On Windows, do not create a new console window.981982[More info.](windows.md#console-window)983984### options.windowsVerbatimArguments985Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 986–987why, one step back986_Type:_ `boolean`\987_Default:_ `true` if the [`shell`](#optionsshell) option is `true`, `false` otherwiseMove API reference to its own page (#996)ehmickybefore adoption7cde496
lines 988–1002why, one step back988989If `false`, escapes the command arguments on Windows.990991[More info.](windows.md#cmdexe-escaping)992993## Transform options994995A transform or an [array of transforms](transform.md#combining) can be passed to the [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) or [`stdio`](#optionsstdio) option.996997A transform is either a [generator function](#transformoptionstransform) or a plain object with the following members.998999[More info.](transform.md)10001001### transformOptions.transform1002Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 1003why, one step back1003_Type:_ `GeneratorFunction<string | Uint8Array | unknown>` | `AsyncGeneratorFunction<string | Uint8Array | unknown>`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1004–1010why, one step back10041005Map or [filter](transform.md#filtering) the [input](input.md) or [output](output.md) of the subprocess.10061007More info [here](transform.md#summary) and [there](transform.md#sharing-state).10081009### transformOptions.final1010Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
line 1011why, one step back1011_Type:_ `GeneratorFunction<string | Uint8Array | unknown>` | `AsyncGeneratorFunction<string | Uint8Array | unknown>`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1012–1018why, one step back10121013Create additional lines after the last one.10141015[More info.](transform.md#finalizing)10161017### transformOptions.binary1018Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1019–1020why, one step back1019_Type:_ `boolean`\1020_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1021–1027why, one step back10211022If `true`, iterate over arbitrary chunks of `Uint8Array`s instead of line `string`s.10231024[More info.](binary.md#transforms)10251026### transformOptions.preserveNewlines1027Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1028–1029why, one step back1028_Type:_ `boolean`\1029_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1030–1036why, one step back10301031If `true`, keep newlines in each `line` argument. Also, this allows multiple `yield`s to produces a single line.10321033[More info.](lines.md#transforms)10341035### transformOptions.objectMode1036Fix style inconsistency in API reference (#1010)ehmickybefore adoption42bea7f
lines 1037–1038why, one step back1037_Type:_ `boolean`\1038_Default:_ `false`Move API reference to its own page (#996)ehmickybefore adoption7cde496
lines 1039–1047why, one step back10391040If `true`, allow [`transformOptions.transform`](#transformoptionstransform) and [`transformOptions.final`](#transformoptionsfinal) to return any type, not just `string` or `Uint8Array`.10411042[More info.](transform.md#object-mode)10431044<hr>10451046[**Previous**: 🔍 Differences with Bash and zx](bash.md)\1047[**Top**: Table of contents](../readme.md#documentation)