Bun.spawn() 을 사용할 때 자식 프로세스는 생성 프로세스의 stderr 을 상속합니다. 대신 stderr 을 읽고 처리하려면 stderr 옵션을 "pipe" 로 설정합니다.
ts
const proc = Bun.spawn(["echo", "hello"], {
stderr: "pipe",
});
proc.stderr; // => ReadableStream자식 프로세스가 종료될 때까지 stderr 을 읽으려면 .text() 를 사용합니다.
ts
const proc = Bun.spawn(["echo", "hello"], {
stderr: "pipe",
});
const errors: string = await proc.stderr.text();
if (errors) {
// 오류 처리
}전체 문서는 문서 > API > 자식 프로세스 를 참조하세요.