denoland/deno · error · TypeError
Piped stdin is not supported for this function, use 'Deno.Co
Error message
Piped stdin is not supported for this function, use 'Deno.Command.spawn()' instead
What it means
Deno.Command.prototype.output() rejects stdin: "piped" with a TypeError because output() resolves only after the child exits, leaving no way to write to a piped stdin. To feed a process input you must keep a live ChildProcess from spawn() and use its .stdin WritableStream.
Source
Thrown at ext/process/40_process.js:802
}
return result.stderr;
},
};
return output;
}
class Command {
#command;
#options;
constructor(command, options) {
this.#command = command;
this.#options = options;
}
output() {
if (this.#options?.stdin === "piped") {
throw new TypeError(
"Piped stdin is not supported for this function, use 'Deno.Command.spawn()' instead",
);
}
return spawnInner(this.#command, this.#options);
}
outputSync() {
if (this.#options?.stdin === "piped") {
throw new TypeError(
"Piped stdin is not supported for this function, use 'Deno.Command.spawn()' instead",
);
}
return spawnSyncInner(this.#command, this.#options);
}
spawn() {
const options = {
__proto__: null,View on GitHub (pinned to 9ad36f7a2c)
Solutions
- Call cmd.spawn() instead of cmd.output(), write to child.stdin, then await child.output() for the collected result
- Drop stdin: "piped" (use "inherit"/"null") if the child needs no input
- Split your options: one preset without piped stdin for output(), one with it for spawn()
Example fix
// before
const cmd = new Deno.Command("cat", { stdin: "piped" });
const out = await cmd.output(); // TypeError
// after
const cmd = new Deno.Command("cat", { stdin: "piped", stdout: "piped" });
const child = cmd.spawn();
const w = child.stdin.getWriter();
await w.write(new TextEncoder().encode("hello"));
await w.close();
const out = await child.output(); Defensive patterns
Strategy: validation
Validate before calling
function runCommand(cmd: Deno.Command, wantsStdin: boolean) {
if (wantsStdin) {
const child = cmd.spawn();
return { child, write: child.stdin.getWriter().write.bind(child.stdin.getWriter()) };
}
return { out: cmd.output() };
} Type guard
const needsInteractiveStdin = (o: Deno.CommandOptions | undefined): boolean => o?.stdin === "piped";
Prevention
- Decide per call: spawn() for interactive stdin, output() otherwise
- Never put stdin: "piped" into shared option presets used by output()
- Write to child.stdin, close the writer, then await child.output() for the result
When it happens
Trigger: const cmd = new Deno.Command("cat", { stdin: "piped" }); await cmd.output(); — also any shared options object with stdin: "piped" passed to a Command whose .output() is later called.
Common situations: Building one Command/options object and wanting both interactive writes and a final result; porting from APIs where exec accepted stdin; wrappers that offer either output() or spawn() behind the same options.
Related errors
- Piped stdin is not supported for this function, use 'Deno.Co
- Cannot collect output: 'stdout' is locked
- Cannot collect output: 'stderr' is locked
- ${prefix}Linter plugin name must only contain lowercase lett
- ${prefix}Linter plugin name must start and end with a lowerc
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/ca4c339b33b2c67e.
Report an issue: GitHub.