rembrembdocs

Skip to main content

Bun home pagelight logodark logo

[Runtime

](../../../index.md)[Package Manager

](../../../pm/cli/install/index.md)[Bundler

](../../../bundler/index.md)[Test Runner

](../../../test/index.md)[Guides

](../../index.md)[Reference

](https://bun.com/reference)[Blog

](https://bun.com/blog)[Feedback

](../../../feedback/index.md)

When using Bun.spawn(), the child process inherits the stderr of the spawning process. If instead you’d prefer to read and handle stderr, set the stderr option to "pipe".

const proc = Bun.spawn(["echo", "hello"], {
  stderr: "pipe",
});

proc.stderr; // => ReadableStream

To read stderr until the child process exits, use .text()

const proc = Bun.spawn(["echo", "hello"], {
  stderr: "pipe",
});

const errors: string = await proc.stderr.text();
if (errors) {
  // handle errors
}

See Docs > API > Child processes for complete documentation.

Was this page helpful?

Suggest editsRaise issue

[

Read stdout from a child process

Previous

](../spawn-stdout/index.md)[

Parse command-line arguments

Next

](../argv/index.md)