Skip to content
Myr

api.md

This file

Path

docs/api.md

1,307 lines · 51.1 KiB · Markdown

Last changed by

Generalize `{value, input}` to any direction-ambiguous stdio value (#1249)Sindre Sorhusbefore adoption9fbf5ba

History of this file

Take it

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

lines 1–8why, 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 reference8

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 9why, one step back
9This lists all available [methods](#methods) and their [options](#options-1). This also describes the properties of the [subprocess](#subprocess), [result](#result) and [error](#execaerror) they return.

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

lines 10–16why, one step back
10
11## Methods1213### execa(file, arguments?, options?)1415`file`: `string | URL`\16`arguments`: `string[]`\

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 17why, one step back
17`options`: [`Options`](#options-1)\

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–23why, 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).23

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 24why, one step back
24### $(file, arguments?, options?)

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

line 25why, one step back
25

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 26–28why, one step back
26`file`: `string | URL`\
27`arguments`: `string[]`\28`options`: [`Options`](#options-1)\

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

line 30why, one step back
30

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 31why, one step back
31Same as [`execa()`](#execafile-arguments-options) but using [script-friendly default options](scripts.md#script-files).

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

line 32why, one step back
32

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 33why, one step back
33This is the preferred method when executing multiple commands in a script file.

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

line 34why, one step back
34

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 35why, one step back
35[More info.](scripts.md)

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

line 36why, one step back
36

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 37why, one step back
37### execaNode(scriptPath, arguments?, options?)

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

line 38why, one step back
38

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 39–42why, one step back
39`scriptPath`: `string | URL`\
40`arguments`: `string[]`\41`options`: [`Options`](#options-1)\42_Returns_: [`ResultPromise`](#return-value)

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

line 43why, one step back
43

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 44–45why, one step back
44Same as [`execa()`](#execafile-arguments-options) but using the [`node: true`](#optionsnode) option.
45Executes a Node.js file using `node scriptPath ...arguments`.

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

line 46why, one step back
46

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 47–50why, one step back
47This is the preferred method when executing Node.js files.
4849[More info.](node.md)50

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

line 51why, one step back
51### execaSync(file, arguments?, options?)

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 52–53why, one step back
52### $.sync(file, arguments?, options?)
53### $.s(file, arguments?, options?)

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

line 54why, one step back
54

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 55–57why, one step back
55`file`: `string | URL`\
56`arguments`: `string[]`\57`options`: [`SyncOptions`](#options-1)\

Rename some types (#1009)ehmickybefore adoption2ef9186

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

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

line 59why, one step back
59

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 60why, one step back
60Same as [`execa()`](#execafile-arguments-options) and [`$`](#file-arguments-options) but synchronous.

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

line 61why, one step back
61

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 62why, one step back
62Returns a subprocess [`result`](#result) or throws an [`error`](#execasyncerror). The [`subprocess`](#subprocess) is not returned: its methods and properties are not available.

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

line 63why, one step back
63

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 64–65why, one step back
64Those methods are discouraged as they hold the CPU and lack multiple features.
65

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

lines 66–67why, one step back
66[More info.](execution.md#synchronous-execution)
67

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 68–73why, one step back
68### execa\`command\`
69### $\`command\`70### execaNode\`command\`71### execaSync\`command\`72### $.sync\`command\`73### $.s\`command\`

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

line 74why, one step back
74

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 75–76why, one step back
75`command`: `string`\
76_Returns_: [`ResultPromise`](#return-value), [`SyncResult`](#return-value)

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

line 77why, one step back
77

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 78why, one step back
78Same as [`execa()`](#execafile-arguments-options), [`$()`](#file-arguments-options), [`execaNode()`](#execanodescriptpath-arguments-options) and [`execaSync()`](#execasyncfile-arguments-options) but using a [template string](execution.md#template-string-syntax). `command` includes both the `file` and its `arguments`.

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

line 79why, one step back
79

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 80why, one step back
80More info on the [syntax](execution.md#template-string-syntax) and [escaping](escaping.md#template-string-syntax).

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

line 81why, one step back
81

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 82–87why, one step back
82### execa(options)\`command\`
83### $(options)\`command\`84### execaNode(options)\`command\`85### execaSync(options)\`command\`86### $.sync(options)\`command\`87### $.s(options)\`command\`

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

line 88why, one step back
88

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 89–91why, one step back
89`command`: `string`\
90`options`: [`Options`](#options-1), [`SyncOptions`](#options-1)\91_Returns_: [`ResultPromise`](#return-value), [`SyncResult`](#return-value)

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

line 92why, one step back
92

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 93why, one step back
93Same as [```execa`command` ```](#execacommand) but with [options](#options-1).

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

line 94why, one step back
94

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 95why, one step back
95[More info.](execution.md#template-string-syntax)

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

line 96why, one step back
96

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 97–102why, one step back
97### execa(options)
98### $(options)99### execaNode(options)100### execaSync(options)101### $.sync(options)102### $.s(options)

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

line 103why, one step back
103

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

lines 104–105why, one step back
104`options`: [`Options`](#options-1), [`SyncOptions`](#options-1)\
105_Returns_: [`ExecaMethod`](#execafile-arguments-options), [`ExecaScriptMethod`](#file-arguments-options), [`ExecaNodeMethod`](#execanodescriptpath-arguments-options), [`ExecaSyncMethod`](#execasyncfile-arguments-options), [`ExecaScriptSyncMethod`](#syncfile-arguments-options)

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

line 106why, one step back
106

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 107why, one step back
107Returns a new instance of those methods but with different default [`options`](#options-1). Consecutive calls are merged to previous ones.

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

line 108why, one step back
108

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 109why, one step back
109[More info.](execution.md#globalshared-options)

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

line 110why, one step back
110

Add `parseCommandString()` (#1054)ehmickybefore adoptionb9474c3

line 111why, one step back
111### parseCommandString(command)

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

lines 112–113why, one step back
112
113`command`: `string`\

Add `parseCommandString()` (#1054)ehmickybefore adoptionb9474c3

line 114why, one step back
114_Returns_: `string[]`

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

line 115why, one step back
115

Add `parseCommandString()` (#1054)ehmickybefore adoptionb9474c3

line 116why, one step back
116Split 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 117–119why, one step back
117
118[More info.](escaping.md#user-defined-input)119

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

line 120why, one step back
120### sendMessage(message, sendMessageOptions?)

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 121–122why, one step back
121
122`message`: [`Message`](ipc.md#message-type)\

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

line 123why, one step back
123`sendMessageOptions`: [`SendMessageOptions`](#sendmessageoptions)\

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 124–131why, one step back
124_Returns_: `Promise<void>`
125126Send a `message` to the parent process.127128This requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.129130[More info.](ipc.md#exchanging-messages)131

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

lines 132–144why, one step back
132#### sendMessageOptions
133134_Type_: `object`135136#### sendMessageOptions.strict137138_Type_: `boolean`\139_Default_: `false`140141Throw when the other process is not receiving or listening to messages.142143[More info.](ipc.md#ensure-messages-are-received)144

Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052

line 145why, one step back
145### getOneMessage(getOneMessageOptions?)

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 146why, one step back
146

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

line 147why, one step back
147`getOneMessageOptions`: [`GetOneMessageOptions`](#getonemessageoptions)\

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 148–155why, one step back
148_Returns_: [`Promise<Message>`](ipc.md#message-type)
149150Receive a single `message` from the parent process.151152This requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.153154[More info.](ipc.md#exchanging-messages)155

Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052

lines 156–167why, one step back
156#### getOneMessageOptions
157158_Type_: `object`159160#### getOneMessageOptions.filter161162_Type_: [`(Message) => boolean`](ipc.md#message-type)163164Ignore any `message` that returns `false`.165166[More info.](ipc.md#filter-messages)167

Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6

line 168why, one step back
168#### getOneMessageOptions.reference

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 169why, one step back
169

Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6

lines 170–179why, one step back
170_Type_: `boolean`\
171_Default_: `true`172173Keep the subprocess alive while `getOneMessage()` is waiting.174175[More info.](ipc.md#keeping-the-subprocess-alive)176177### getEachMessage(getEachMessageOptions?)178179`getEachMessageOptions`: [`GetEachMessageOptions`](#geteachmessageoptions)\

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 180–187why, one step back
180_Returns_: [`AsyncIterable<Message>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)
181182Iterate over each `message` from the parent process.183184This requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.185186[More info.](ipc.md#listening-to-messages)187

Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6

lines 188–200why, one step back
188#### getEachMessageOptions
189190_Type_: `object`191192#### getEachMessageOptions.reference193194_Type_: `boolean`\195_Default_: `true`196197Keep the subprocess alive while `getEachMessage()` is waiting.198199[More info.](ipc.md#keeping-the-subprocess-alive)200

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

lines 201–210why, one step back
201### getCancelSignal()
202203_Returns_: [`Promise<AbortSignal>`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal)204205Retrieves the [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) shared by the [`cancelSignal`](#optionscancelsignal) option.206207This can only be called inside a subprocess. This requires the [`gracefulCancel`](#optionsgracefulcancel) option to be `true`.208209[More info.](termination.md#graceful-termination)210

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

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

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

line 212why, one step back
212

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

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

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

line 215why, one step back
215

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

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

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

lines 217–218why, one step back
217- the [subprocess](#subprocess).
218- 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 219–221why, one step back
219
220[More info.](execution.md#subprocess)221

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

lines 222–223why, one step back
222## Subprocess
223

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

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

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

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

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

lines 228–248why, one step back
228### subprocess\[Symbol.asyncIterator\]()
229230_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)231232Subprocesses are [async iterables](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator). They iterate over each output line.233234[More info.](lines.md#progressive-splitting)235236### subprocess.iterable(readableOptions?)237238`readableOptions`: [`ReadableOptions`](#readableoptions)\239_Returns_: [`AsyncIterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)240241Same as [`subprocess[Symbol.asyncIterator]`](#subprocesssymbolasynciterator) except [options](#readableoptions) can be provided.242243[More info.](lines.md#progressive-splitting)244245### subprocess.pipe(file, arguments?, options?)246247`file`: `string | URL`\248`arguments`: `string[]`\

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 249why, one step back
249`options`: [`Options`](#options-1) and [`PipeOptions`](#pipeoptions)\

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

lines 250–253why, one step back
250_Returns_: [`Promise<Result>`](#result)
251252[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.253

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 254why, one step back
254This follows the same syntax as [`execa(file, arguments?, options?)`](#execafile-arguments-options) except both [regular options](#options-1) and [pipe-specific options](#pipeoptions) can be specified.

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

lines 255–261why, one step back
255
256[More info.](pipe.md#array-syntax)257258### subprocess.pipe\`command\`259### subprocess.pipe(options)\`command\`260261`command`: `string`\

Improve documentation of Execa methods (#1115)ehmickybefore adoptionca2e813

line 262why, one step back
262`options`: [`Options`](#options-1) and [`PipeOptions`](#pipeoptions)\

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

lines 263–264why, one step back
263_Returns_: [`Promise<Result>`](#result)
264

Fix broken Markdown links (#1119)ehmickybefore adoption8572eb1

line 265why, one step back
265Like [`subprocess.pipe(file, arguments?, options?)`](#subprocesspipefile-arguments-options) but using a [`command` template string](execution.md#template-string-syntax) instead. This follows the same syntax as `execa` [template strings](execution.md#template-string-syntax).

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

lines 266–270why, one step back
266
267[More info.](pipe.md#template-string-syntax)268269### subprocess.pipe(secondSubprocess, pipeOptions?)270

Rename some types (#1009)ehmickybefore adoption2ef9186

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

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

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

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

line 275why, one step back
275Like [`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 276–280why, one step back
276
277[More info.](pipe.md#advanced-syntax)278279#### pipeOptions280

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

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

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

lines 282–284why, one step back
282
283#### pipeOptions.from284

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

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

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

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

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

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

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

lines 298–304why, one step back
298
299Which [stream](#subprocessstdin) to pipe to the destination subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.300301[More info.](pipe.md#destination-file-descriptor)302303#### pipeOptions.unpipeSignal304

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

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

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

lines 306–317why, one step back
306
307Unpipe the subprocess when the signal aborts.308309[More info.](pipe.md#unpipe)310311### subprocess.kill(signal, error?)312### subprocess.kill(error?)313314`signal`: `string | number`\315`error`: `Error`\316_Returns_: `boolean`317

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

line 318why, one step back
318Sends 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 319–327why, one step back
319
320This returns `false` when the signal could not be sent, for example when the subprocess has already exited.321322When 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).323324[More info.](termination.md)325326### subprocess.pid327

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

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

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

lines 329–335why, one step back
329
330Process identifier ([PID](https://en.wikipedia.org/wiki/Process_identifier)).331332This is `undefined` if the subprocess failed to spawn.333334[More info.](termination.md#inter-process-termination)335

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

line 336why, one step back
336### subprocess.sendMessage(message, sendMessageOptions)

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

line 337why, one step back
337

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 338why, one step back
338`message`: [`Message`](ipc.md#message-type)\

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

line 339why, one step back
339`sendMessageOptions`: [`SendMessageOptions`](#sendmessageoptions)\

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 340why, one step back
340_Returns_: `Promise<void>`

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

line 341why, one step back
341

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 342why, one step back
342Send a `message` to the subprocess.

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

line 343why, one step back
343

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 344why, one step back
344This requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.

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

lines 345–347why, one step back
345
346[More info.](ipc.md#exchanging-messages)347

Add `filter` option to `getOneMessage()` (#1076)ehmickybefore adoption571e052

line 348why, one step back
348### subprocess.getOneMessage(getOneMessageOptions?)

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

line 349why, one step back
349

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

line 350why, one step back
350`getOneMessageOptions`: [`GetOneMessageOptions`](#getonemessageoptions)\

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 351why, one step back
351_Returns_: [`Promise<Message>`](ipc.md#message-type)

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

line 352why, one step back
352

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 353why, one step back
353Receive a single `message` from the subprocess.

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

line 354why, one step back
354

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 355why, one step back
355This requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.

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

lines 356–358why, one step back
356
357[More info.](ipc.md#exchanging-messages)358

Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6

line 359why, one step back
359### subprocess.getEachMessage(getEachMessageOptions?)

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

line 360why, one step back
360

Add `reference` option to `getOneMessage()` and `getEachMessage()` (#1107)ehmickybefore adoptionff02af6

line 361why, one step back
361`getEachMessageOptions`: [`GetEachMessageOptions`](#geteachmessageoptions)\

Add promise-based IPC (#1059)ehmickybefore adoptionacc2b68

lines 362–369why, one step back
362_Returns_: [`AsyncIterable<Message>`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols)
363364Iterate over each `message` from the subprocess.365366This requires the [`ipc`](#optionsipc) option to be `true`. The [type](ipc.md#message-type) of `message` depends on the [`serialization`](#optionsserialization) option.367368[More info.](ipc.md#listening-to-messages)369

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

lines 370–371why, one step back
370### subprocess.stdin
371

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

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

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

lines 373–381why, one step back
373
374The subprocess [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)) as a stream.375376This 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).377378[More info.](streams.md#manual-streaming)379380### subprocess.stdout381

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

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

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

lines 383–391why, one step back
383
384The subprocess [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)) as a stream.385386This 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`.387388[More info.](streams.md#manual-streaming)389390### subprocess.stderr391

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

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

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

lines 393–401why, one step back
393
394The subprocess [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)) as a stream.395396This 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`.397398[More info.](streams.md#manual-streaming)399400### subprocess.all401

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

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

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

lines 403–413why, one step back
403
404Stream combining/interleaving [`subprocess.stdout`](#subprocessstdout) and [`subprocess.stderr`](#subprocessstderr).405406This requires the [`all`](#optionsall) option to be `true`.407408This 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`.409410More info on [interleaving](output.md#interleaved-output) and [streaming](streams.md#manual-streaming).411412### subprocess.stdio413

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

line 414why, one step back
414_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 415–432why, one step back
415
416The subprocess [`stdin`](#subprocessstdin), [`stdout`](#subprocessstdout), [`stderr`](#subprocessstderr) and [other files descriptors](#optionsstdio) as an array of streams.417418Each 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`.419420[More info.](streams.md#manual-streaming)421422### subprocess.readable(readableOptions?)423424`readableOptions`: [`ReadableOptions`](#readableoptions)\425_Returns_: [`Readable`](https://nodejs.org/api/stream.html#class-streamreadable) Node.js stream426427Converts the subprocess to a readable stream.428429[More info.](streams.md#converting-a-subprocess-to-a-stream)430431#### readableOptions432

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

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

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

lines 434–436why, one step back
434
435#### readableOptions.from436

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

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

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

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

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

lines 448–449why, one step back
448_Type:_ `boolean`\
449_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 450–460why, one step back
450
451If `false`, iterates over lines. Each line is a string.452453If `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)).454455This is always `true` when the [`encoding`](#optionsencoding) option is binary.456457More info for [iterables](binary.md#iterable) and [streams](binary.md#streams).458459#### readableOptions.preserveNewlines460

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

lines 461–462why, one step back
461_Type:_ `boolean`\
462_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 463–478why, one step back
463
464If both this option and the [`binary`](#readableoptionsbinary) option is `false`, [newlines](https://en.wikipedia.org/wiki/Newline) are stripped from each line.465466[More info.](lines.md#iterable)467468### subprocess.writable(writableOptions?)469470`writableOptions`: [`WritableOptions`](#writableoptions)\471_Returns_: [`Writable`](https://nodejs.org/api/stream.html#class-streamwritable) Node.js stream472473Converts the subprocess to a writable stream.474475[More info.](streams.md#converting-a-subprocess-to-a-stream)476477#### writableOptions478

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

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

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

lines 480–482why, one step back
480
481#### writableOptions.to482

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

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

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

lines 485–500why, one step back
485
486Which [stream](#subprocessstdin) to write to the subprocess. A [file descriptor](https://en.wikipedia.org/wiki/File_descriptor) like `"fd3"` can also be passed.487488[More info.](streams.md#different-file-descriptor)489490### subprocess.duplex(duplexOptions?)491492`duplexOptions`: [`ReadableOptions | WritableOptions`](#readableoptions)\493_Returns_: [`Duplex`](https://nodejs.org/api/stream.html#class-streamduplex) Node.js stream494495Converts the subprocess to a duplex stream.496497[More info.](streams.md#converting-a-subprocess-to-a-stream)498499## Result500

Improve documentation of signal handling (#1105)ehmickybefore adoption01a4b42

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

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

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

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

line 503why, one step back
503

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

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

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

lines 505–509why, one step back
505
506When the subprocess [fails](errors.md#subprocess-failure), it is rejected with an [`ExecaError`](#execaerror) instead.507508### result.stdout509

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

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

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

lines 511–521why, one step back
511
512The output of the subprocess on [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)).513514This 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`.515516This 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).517518[More info.](output.md#stdout-and-stderr)519520### result.stderr521

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

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

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

lines 523–533why, one step back
523
524The output of the subprocess on [`stderr`](https://en.wikipedia.org/wiki/Standard_streams#Standard_error_(stderr)).525526This 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`.527528This 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).529530[More info.](output.md#stdout-and-stderr)531532### result.all533

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

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

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

lines 535–547why, one step back
535
536The output of the subprocess with [`result.stdout`](#resultstdout) and [`result.stderr`](#resultstderr) interleaved.537538This requires the [`all`](#optionsall) option to be `true`.539540This 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`.541542This 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).543544[More info.](output.md#interleaved-output)545546### result.stdio547

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

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

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

lines 549–557why, one step back
549
550The output of the subprocess on [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) and [other file descriptors](#optionsstdio).551552Items 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`.553554Items are arrays when their corresponding `stdio` option is a [transform in object mode](transform.md#object-mode).555556[More info.](output.md#additional-file-descriptors)557

Rename `result.ipc` to `result.ipcOutput` (#1075)ehmickybefore adoptionae9b360

line 558why, one step back
558### result.ipcOutput

Add `result.ipc`/`error.ipc` (#1067)ehmickybefore adoption3ab34de

line 559why, one step back
559

Fix type of `result.ipc` (#1071)ehmickybefore adoption69152ec

line 560why, one step back
560_Type_: [`Message[]`](ipc.md#message-type)

Add `result.ipc`/`error.ipc` (#1067)ehmickybefore adoption3ab34de

line 561why, one step back
561

Add `strict` option to `sendMessage()` (#1098)ehmickybefore adoptione085b10

line 562why, one step back
562All the messages [sent by the subprocess](#sendmessagemessage-sendmessageoptions) to the current process.

Add `result.ipc`/`error.ipc` (#1067)ehmickybefore adoption3ab34de

lines 563–567why, one step back
563
564This is empty unless the [`ipc`](#optionsipc) option is `true`. Also, this is empty if the [`buffer`](#optionsbuffer) option is `false`.565566[More info.](ipc.md#retrieve-all-messages)567

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

lines 568–569why, one step back
568### result.pipedFrom
569

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

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

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

lines 571–579why, one step back
571
572[Results](#result) of the other subprocesses that were piped into this subprocess.573574This array is initially empty and is populated each time the [`subprocess.pipe()`](#subprocesspipefile-arguments-options) method resolves.575576[More info.](pipe.md#result)577578### result.command579

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

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

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

lines 581–587why, one step back
581
582The file and [arguments](input.md#command-arguments) that were run.583584[More info.](debugging.md#command)585586### result.escapedCommand587

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

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

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

lines 589–595why, one step back
589
590Same as [`command`](#resultcommand) but escaped.591592[More info.](debugging.md#command)593594### result.cwd595

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

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

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

lines 597–603why, one step back
597
598The [current directory](#optionscwd) in which the command was run.599600[More info.](environment.md#current-directory)601602### result.durationMs603

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

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

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

lines 605–611why, one step back
605
606Duration of the subprocess, in milliseconds.607608[More info.](debugging.md#duration)609610### result.failed611

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

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

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

lines 613–615why, one step back
613
614Whether the subprocess failed to run.615

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

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

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

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

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

lines 620–621why, one step back
620## ExecaError
621## ExecaSyncError

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

line 622why, one step back
622

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

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

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

lines 624–634why, one step back
624
625Result of a subprocess [failed execution](errors.md#subprocess-failure).626627This error is thrown as an exception. If the [`reject`](#optionsreject) option is false, it is returned instead.628629This has the same shape as [successful results](#result), with the following additional properties.630631[More info.](errors.md)632633### error.message634

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

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

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

lines 636–642why, one step back
636
637Error message when the subprocess [failed](errors.md#subprocess-failure) to run.638639[More info.](errors.md#error-message)640641### error.shortMessage642

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

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

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

lines 644–650why, one step back
644
645This is the same as [`error.message`](#errormessage) except it does not include the subprocess [output](output.md).646647[More info.](errors.md#error-message)648649### error.originalMessage650

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

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

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

lines 652–658why, one step back
652
653Original error message. This is the same as [`error.message`](#errormessage) excluding the subprocess [output](output.md) and some additional information added by Execa.654655[More info.](errors.md#error-message)656657### error.cause658

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

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

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

lines 660–668why, one step back
660
661Underlying error, if there is one. For example, this is set by [`subprocess.kill(error)`](#subprocesskillerror).662663This is usually an `Error` instance.664665[More info.](termination.md#error-message-and-stack-trace)666667### error.code668

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

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

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

lines 670–674why, one step back
670
671Node.js-specific [error code](https://nodejs.org/api/errors.html#errorcode), when available.672673### error.timedOut674

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

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

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

lines 676–680why, one step back
676
677Whether the subprocess timed out due to the [`timeout`](#optionstimeout) option.678679[More info.](termination.md#timeout)680

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

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

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

line 682why, one step back
682

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

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

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

lines 684–688why, one step back
684
685Whether the subprocess was canceled using the [`cancelSignal`](#optionscancelsignal) option.686687[More info.](termination.md#canceling)688

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

lines 689–696why, one step back
689### error.isGracefullyCanceled
690691_Type:_ `boolean`692693Whether the subprocess was canceled using both the [`cancelSignal`](#optionscancelsignal) and the [`gracefulCancel`](#optionsgracefulcancel) options.694695[More info.](termination.md#graceful-termination)696

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

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

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

line 698why, one step back
698

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

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

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

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

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

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

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

line 706why, one step back
706

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

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

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

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

Add `error.isForcefullyTerminated` (#1111)ehmickybefore adoptione69985d

lines 715–722why, one step back
715### error.isForcefullyTerminated
716717_Type:_ `boolean`718719Whether the subprocess was terminated by the [`SIGKILL`](termination.md#sigkill) signal sent by the [`forceKillAfterDelay`](#optionsforcekillafterdelay) option.720721[More info.](termination.md#forceful-termination)722

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

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

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

line 724why, one step back
724

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

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

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

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

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

line 729why, one step back
729This 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 730–732why, one step back
730
731[More info.](errors.md#exit-code)732

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

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

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

line 734why, one step back
734

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

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

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

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

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

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

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

line 746why, one step back
746

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

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

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

lines 748–756why, one step back
748
749A human-friendly description of the [signal](termination.md#signal-termination) that was used to terminate the subprocess.750751If 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.752753[More info.](termination.md#signal-name-and-description)754755## Options756

Fix a typo (#1153)Reuben Thomasbefore adoption3fc8049

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

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

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

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

lines 759–765why, one step back
759
760This lists all options for [`execa()`](#execafile-arguments-options) and the [other methods](#methods).761762The 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).763764### options.preferLocal765

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

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

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

lines 768–774why, one step back
768
769Prefer locally installed binaries when looking for a binary to execute.770771[More info.](environment.md#local-binaries)772773### options.localDir774

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

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

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

lines 777–783why, one step back
777
778Preferred path to find locally installed binaries, when using the [`preferLocal`](#optionspreferlocal) option.779780[More info.](environment.md#local-binaries)781782### options.node783

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

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

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

lines 786–788why, one step back
786
787If `true`, runs with Node.js. The first argument must be a Node.js file.788

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

lines 789–790why, one step back
789The 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.
790

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

lines 791–794why, one step back
791[More info.](node.md)
792793### options.nodeOptions794

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

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

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

line 796why, one step back
796_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 797–805why, one step back
797
798List of [CLI flags](https://nodejs.org/api/cli.html#cli_options) passed to the [Node.js executable](#optionsnodepath).799800Requires the [`node`](#optionsnode) option to be `true`.801802[More info.](node.md#nodejs-cli-flags)803804### options.nodePath805

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

lines 806–807why, one step back
806_Type:_ `string | URL`\
807_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 808–816why, one step back
808
809Path to the Node.js executable.810811Requires the [`node`](#optionsnode) option to be `true`.812813[More info.](node.md#nodejs-version)814815### options.shell816

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

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

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

lines 819–829why, one step back
819
820If `true`, runs the command inside of a [shell](https://en.wikipedia.org/wiki/Shell_(computing)).821822Uses [`/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.823824We [recommend against](shell.md#avoiding-shells) using this option.825826[More info.](shell.md)827828### options.cwd829

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

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

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

lines 832–840why, one step back
832
833Current [working directory](https://en.wikipedia.org/wiki/Working_directory) of the subprocess.834835This is also used to resolve the [`nodePath`](#optionsnodepath) option when it is a relative path.836837[More info.](environment.md#current-directory)838839### options.env840

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

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

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

lines 843–851why, one step back
843
844[Environment variables](https://en.wikipedia.org/wiki/Environment_variable).845846Unless the [`extendEnv`](#optionsextendenv) option is `false`, the subprocess also uses the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).847848[More info.](input.md#environment-variables)849850### options.extendEnv851

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

lines 852–853why, one step back
852_Type:_ `boolean`\
853_Default:_ `true`

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

lines 854–861why, one step back
854
855If `true`, the subprocess uses both the [`env`](#optionsenv) option and the current process' environment variables ([`process.env`](https://nodejs.org/api/process.html#processenv)).856If `false`, only the `env` option is used, not `process.env`.857858[More info.](input.md#environment-variables)859860### options.input861

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

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

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

lines 863–871why, one step back
863
864Write some input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).865866See also the [`inputFile`](#optionsinputfile) and [`stdin`](#optionsstdin) options.867868[More info.](input.md#string-input)869870### options.inputFile871

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

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

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

lines 873–881why, one step back
873
874Use a file as input to the subprocess' [`stdin`](https://en.wikipedia.org/wiki/Standard_streams#Standard_input_(stdin)).875876See also the [`input`](#optionsinput) and [`stdin`](#optionsstdin) options.877878[More info.](input.md#file-input)879880### options.stdin881

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

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

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

lines 883–884why, one step back
883_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)\
884_Default:_ `'inherit'` with [`$`](#file-arguments-options), `'pipe'` otherwise

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

lines 885–893why, one step back
885
886How 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).887888This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.889890More info on [available values](input.md), [streaming](streams.md) and [transforms](transform.md).891892### options.stdout893

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

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

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

lines 895–896why, one step back
895_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)\
896_Default:_ `pipe`

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

lines 897–905why, one step back
897
898How 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).899900This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.901902More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).903904### options.stderr905

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

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

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

lines 907–908why, one step back
907_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)\
908_Default:_ `pipe`

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

lines 909–917why, one step back
909
910How 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).911912This can be an [array of values](output.md#multiple-targets) such as `['inherit', 'pipe']` or `[fileUrl, 'pipe']`.913914More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).915916### options.stdio917

Add documentation about TypeScript types (#1015)ehmickybefore adoptionf79e058

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

Generalize `{value, input}` to any direction-ambiguous stdio value (#1249)Sindre Sorhusbefore adoption9fbf5ba

line 919why, one step back
919_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} | {value: 'pipe' | 'inherit' | number | URL | {file: string} | GeneratorFunction<string | Uint8Array | unknown> | AsyncGeneratorFunction<string | Uint8Array | unknown> | {transform: GeneratorFunction | AsyncGeneratorFunction | Duplex | TransformStream}; input?: boolean}>` (or a tuple of those types)\

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

line 920why, one step back
920_Default:_ `pipe`

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

lines 921–925why, one step back
921
922Like 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'}`.923924A single string can be used [as a shortcut](output.md#shortcut).925

Generalize `{value, input}` to any direction-ambiguous stdio value (#1249)Sindre Sorhusbefore adoption9fbf5ba

line 926why, one step back
926The array can have more than 3 items, to create [additional file descriptors](output.md#additional-file-descriptors) beyond [`stdin`](#optionsstdin)/[`stdout`](#optionsstdout)/[`stderr`](#optionsstderr). Some values have an ambiguous direction on an additional file descriptor (like `'pipe'`, `'inherit'`, a file or a transform), so they default to output. To use one for [input](input.md#additional-file-descriptors) instead, wrap it as `{value, input: true}`.

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

lines 927–931why, one step back
927
928More info on [available values](output.md), [streaming](streams.md) and [transforms](transform.md).929930### options.all931

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

lines 932–933why, one step back
932_Type:_ `boolean`\
933_Default:_ `false`

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

lines 934–940why, one step back
934
935Add a [`subprocess.all`](#subprocessall) stream and a [`result.all`](#resultall) property.936937[More info.](output.md#interleaved-output)938939### options.encoding940

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

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

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

lines 943–947why, one step back
943
944If 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).945946If it outputs binary data instead, this should be either:947- `'buffer'`: returns the binary output as an [`Uint8Array`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array).

Require Node.js 22 (#1243)Sindre Sorhusbefore adoption04b4454

line 948why, one step back
948- [`'hex'`](https://en.wikipedia.org/wiki/Hexadecimal), [`'base64'`](https://en.wikipedia.org/wiki/Base64), [`'base64url'`](https://en.wikipedia.org/wiki/Base64#RFC_4648), [`'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.

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

lines 949–955why, one step back
949
950The output is available with [`result.stdout`](#resultstdout), [`result.stderr`](#resultstderr) and [`result.stdio`](#resultstdio).951952[More info.](binary.md)953954### options.lines955

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

lines 956–957why, one step back
956_Type:_ `boolean`\
957_Default:_ `false`

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

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

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

lines 969–970why, one step back
969_Type:_ `boolean`\
970_Default:_ `true`

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

lines 971–981why, one step back
971
972Strip the final [newline character](https://en.wikipedia.org/wiki/Newline) from the output.973974If the [`lines`](#optionslines) option is true, this applies to each output line instead.975976By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).977978[More info.](lines.md#newlines)979980### options.maxBuffer981

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

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

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

lines 984–988why, one step back
984
985Largest amount of data allowed on [`stdout`](#resultstdout), [`stderr`](#resultstderr) and [`stdio`](#resultstdio).986987By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).988

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

lines 989–990why, one step back
989When reached, [`error.isMaxBuffer`](#errorismaxbuffer) becomes `true`.
990

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

lines 991–994why, one step back
991[More info.](output.md#big-output)
992993### options.buffer994

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

lines 995–996why, one step back
995_Type:_ `boolean`\
996_Default:_ `true`

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

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

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

line 1006why, one step back
1006_Type:_ `boolean`\

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

line 1007why, one step back
1007_Default:_ `true` if the [`node`](#optionsnode), [`ipcInput`](#optionsipcinput) or [`gracefulCancel`](#optionsgracefulcancel) option is set, `false` otherwise

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

line 1008why, one step back
1008

Fix broken Markdown links (#1119)ehmickybefore adoption8572eb1

line 1009why, one step back
1009Enables exchanging messages with the subprocess using [`subprocess.sendMessage(message)`](#subprocesssendmessagemessage-sendmessageoptions), [`subprocess.getOneMessage()`](#subprocessgetonemessagegetonemessageoptions) and [`subprocess.getEachMessage()`](#subprocessgeteachmessagegeteachmessageoptions).

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

line 1010why, one step back
1010

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 1011–1012why, one step back
1011The subprocess must be a Node.js file.
1012

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

lines 1013–1016why, one step back
1013[More info.](ipc.md)
10141015### options.serialization1016

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

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

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

lines 1019–1022why, one step back
1019
1020Specify the kind of serialization used for sending messages between subprocesses when using the [`ipc`](#optionsipc) option.10211022[More info.](ipc.md#message-type)

Add `ipcInput` option (#1068)ehmickybefore adoption46cae30

lines 1023–1032why, one step back
1023
1024### options.ipcInput10251026_Type_: [`Message`](ipc.md#message-type)10271028Sends an IPC message when the subprocess starts.10291030The subprocess must be a [Node.js file](#optionsnode). The value's [type](ipc.md#message-type) depends on the [`serialization`](#optionsserialization) option.10311032More info [here](ipc.md#send-an-initial-message) and [there](input.md#any-input-type).

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

lines 1033–1035why, one step back
1033
1034### options.verbose1035

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

line 1036why, one step back
1036_Type:_ `'none' | 'short' | 'full' | Function`\

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

line 1037why, one step back
1037_Default:_ `'none'`

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

lines 1038–1040why, one step back
1038
1039If `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.1040

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

line 1041why, one step back
1041If `verbose` is `'full'` or a function, the command's [`stdout`](https://en.wikipedia.org/wiki/Standard_streams#Standard_output_(stdout)), `stderr` and [IPC messages](ipc.md) are also printed.

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

line 1042why, one step back
1042

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

lines 1043–1044why, one step back
1043A [function](#verbose-function) can be passed to customize logging. Please see [this page](debugging.md#custom-logging) for more information.
1044

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

lines 1045–1050why, one step back
1045By default, this applies to both `stdout` and `stderr`, but [different values can also be passed](output.md#stdoutstderr-specific-options).
10461047[More info.](debugging.md#verbose-mode)10481049### options.reject1050

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

lines 1051–1052why, one step back
1051_Type:_ `boolean`\
1052_Default:_ `true`

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

line 1053why, one step back
1053

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

line 1054why, one step back
1054Setting 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 1055–1059why, one step back
1055
1056[More info.](errors.md#preventing-exceptions)10571058### options.timeout1059

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

lines 1060–1061why, one step back
1060_Type:_ `number`\
1061_Default:_ `0`

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

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

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

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

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

lines 1066–1070why, one step back
1066
1067[More info.](termination.md#timeout)10681069### options.cancelSignal1070

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

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

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

line 1072why, one step back
1072

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

line 1073why, one step back
1073When the `cancelSignal` is [aborted](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort), terminate the subprocess using a `SIGTERM` signal.

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

line 1074why, one step back
1074

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

line 1075why, one step back
1075When aborted, [`error.isCanceled`](#erroriscanceled) becomes `true`.

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

lines 1076–1077why, one step back
1076
1077[More info.](termination.md#canceling)

Add `gracefulCancel` option (#1109)ehmickybefore adoptiond8190e5

lines 1078–1090why, one step back
1078
1079### options.gracefulCancel10801081_Type:_ `boolean`\1082_Default:_: `false`10831084When the [`cancelSignal`](#optionscancelsignal) option is [aborted](https://developer.mozilla.org/en-US/docs/Web/API/AbortController/abort), do not send any [`SIGTERM`](termination.md#canceling). Instead, abort the [`AbortSignal`](https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal) returned by [`getCancelSignal()`](#getcancelsignal). The subprocess should use it to terminate gracefully.10851086The subprocess must be a [Node.js file](#optionsnode).10871088When aborted, [`error.isGracefullyCanceled`](#errorisgracefullycanceled) becomes `true`.10891090[More info.](termination.md#graceful-termination)

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

lines 1091–1093why, one step back
1091
1092### options.forceKillAfterDelay1093

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

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

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

lines 1096–1097why, one step back
1096
1097If the subprocess is terminated but does not exit, forcefully exit it by sending [`SIGKILL`](https://en.wikipedia.org/wiki/Signal_(IPC)#SIGKILL).

Add `error.isForcefullyTerminated` (#1111)ehmickybefore adoptione69985d

lines 1098–1099why, one step back
1098
1099When this happens, [`error.isForcefullyTerminated`](#errorisforcefullyterminated) becomes `true`.

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

lines 1100–1104why, one step back
1100
1101[More info.](termination.md#forceful-termination)11021103### options.killSignal1104

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

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

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

lines 1107–1115why, one step back
1107
1108Default [signal](https://en.wikipedia.org/wiki/Signal_(IPC)) used to terminate the subprocess.11091110This can be either a name (like [`'SIGTERM'`](termination.md#sigterm)) or a number (like `9`).11111112[More info.](termination.md#default-signal)11131114### options.detached1115

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

lines 1116–1117why, one step back
1116_Type:_ `boolean`\
1117_Default:_ `false`

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

lines 1118–1124why, one step back
1118
1119Run the subprocess independently from the current process.11201121[More info.](environment.md#background-subprocess)11221123### options.cleanup1124

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

lines 1125–1126why, one step back
1125_Type:_ `boolean`\
1126_Default:_ `true`

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

lines 1127–1133why, one step back
1127
1128Kill the subprocess when the current process exits.11291130[More info.](termination.md#current-process-exit)11311132### options.uid1133

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

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

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

lines 1136–1142why, one step back
1136
1137Sets the [user identifier](https://en.wikipedia.org/wiki/User_identifier) of the subprocess.11381139[More info.](windows.md#uid-and-gid)11401141### options.gid1142

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

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

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

lines 1145–1151why, one step back
1145
1146Sets the [group identifier](https://en.wikipedia.org/wiki/Group_identifier) of the subprocess.11471148[More info.](windows.md#uid-and-gid)11491150### options.argv01151

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

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

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

lines 1154–1158why, one step back
1154
1155Value of [`argv[0]`](https://nodejs.org/api/process.html#processargv0) sent to the subprocess.11561157### options.windowsHide1158

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

lines 1159–1160why, one step back
1159_Type:_ `boolean`\
1160_Default:_ `true`

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

lines 1161–1167why, one step back
1161
1162On Windows, do not create a new console window.11631164[More info.](windows.md#console-window)11651166### options.windowsVerbatimArguments1167

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

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

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

lines 1170–1172why, one step back
1170
1171If `false`, escapes the command arguments on Windows.1172

Improve documentation for `windowsVerbatimArguments` (#1149)ehmickybefore adoptionc4cb62a

line 1173why, one step back
1173[More info.](windows.md#escaping)

Allow `verbose` option to be a function for custom logging (#1130)ehmickybefore adoption8daf348

lines 1174–1251why, one step back
1174
1175## Verbose function11761177_Type_: `(string, VerboseObject) => string | undefined`11781179Function passed to the [`verbose`](#optionsverbose) option to customize logging.11801181[More info.](debugging.md#custom-logging)11821183### Verbose object11841185_Type_: `VerboseObject` or `SyncVerboseObject`11861187Subprocess event object, for logging purpose, using the [`verbose`](#optionsverbose) option.11881189#### verboseObject.type11901191_Type_: `string`11921193Event type. This can be:1194- `'command'`: subprocess start1195- `'output'`: `stdout`/`stderr` [output](output.md#stdout-and-stderr)1196- `'ipc'`: IPC [output](ipc.md#retrieve-all-messages)1197- `'error'`: subprocess [failure](errors.md#subprocess-failure)1198- `'duration'`: subprocess success or failure11991200#### verboseObject.message12011202_Type_: `string`12031204Depending on [`verboseObject.type`](#verboseobjecttype), this is:1205- `'command'`: the [`result.escapedCommand`](#resultescapedcommand)1206- `'output'`: one line from [`result.stdout`](#resultstdout) or [`result.stderr`](#resultstderr)1207- `'ipc'`: one IPC message from [`result.ipcOutput`](#resultipcoutput)1208- `'error'`: the [`error.shortMessage`](#errorshortmessage)1209- `'duration'`: the [`result.durationMs`](#resultdurationms)12101211#### verboseObject.escapedCommand12121213_Type_: `string`12141215The file and [arguments](input.md#command-arguments) that were run. This is the same as [`result.escapedCommand`](#resultescapedcommand).12161217#### verboseObject.options12181219_Type_: [`Options`](#options-1) or [`SyncOptions`](#options-1)12201221The [options](#options-1) passed to the subprocess.12221223#### verboseObject.commandId12241225_Type_: `string`12261227Serial number identifying the subprocess within the current process. It is incremented from `'0'`.12281229This is helpful when multiple subprocesses are running at the same time.12301231This is similar to a [PID](https://en.wikipedia.org/wiki/Process_identifier) except it has no maximum limit, which means it never repeats. Also, it is usually shorter.12321233#### verboseObject.timestamp12341235_Type_: `Date`12361237Event date/time.12381239#### verboseObject.result12401241_Type_: [`Result`](#result), [`SyncResult`](#result) or `undefined`12421243Subprocess [result](#result).12441245This is `undefined` if [`verboseObject.type`](#verboseobjecttype) is `'command'`, `'output'` or `'ipc'`.12461247#### verboseObject.piped12481249_Type_: `boolean`12501251Whether another subprocess is [piped](pipe.md) into this subprocess. This is `false` when [`result.pipedFrom`](#resultfailed) is empty.

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

lines 1252–1262why, one step back
1252
1253## Transform options12541255A transform or an [array of transforms](transform.md#combining) can be passed to the [`stdin`](#optionsstdin), [`stdout`](#optionsstdout), [`stderr`](#optionsstderr) or [`stdio`](#optionsstdio) option.12561257A transform is either a [generator function](#transformoptionstransform) or a plain object with the following members.12581259[More info.](transform.md)12601261### transformOptions.transform1262

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

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

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

lines 1264–1270why, one step back
1264
1265Map or [filter](transform.md#filtering) the [input](input.md) or [output](output.md) of the subprocess.12661267More info [here](transform.md#summary) and [there](transform.md#sharing-state).12681269### transformOptions.final1270

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

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

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

lines 1272–1278why, one step back
1272
1273Create additional lines after the last one.12741275[More info.](transform.md#finalizing)12761277### transformOptions.binary1278

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

lines 1279–1280why, one step back
1279_Type:_ `boolean`\
1280_Default:_ `false`

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

lines 1281–1287why, one step back
1281
1282If `true`, iterate over arbitrary chunks of `Uint8Array`s instead of line `string`s.12831284[More info.](binary.md#transforms)12851286### transformOptions.preserveNewlines1287

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

lines 1288–1289why, one step back
1288_Type:_ `boolean`\
1289_Default:_ `false`

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

line 1290why, one step back
1290

Type the `std*` generator transform `chunk` argument (#1247)Sindre Sorhusbefore adoption0a7b4f8

line 1291why, one step back
1291If `true`, keep newlines in each `line` argument. Also, this allows multiple `yield`s to produce a single line.

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

lines 1292–1296why, one step back
1292
1293[More info.](lines.md#transforms)12941295### transformOptions.objectMode1296

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

lines 1297–1298why, one step back
1297_Type:_ `boolean`\
1298_Default:_ `false`

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

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