Skip to main content

Read stdout from a child process

还没翻译译自英文(bun.com)本页 4 段都还没译

When you spawn a child process with Bun.spawn(), proc.stdout is a ReadableStream of the child's stdout.

const proc = Bun.spawn(["echo", "hello"]);

const output = await proc.stdout.text();
output; // => "hello\n"

To pipe the child process's stdout to the parent's stdout instead, set the stdout option to "inherit".

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

See Child processes.

翻訳 © 2026 fanyi.dev · 原文 © 2026 the Bun project (LICENSE.md names no copyright holder) (MIT)