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
spawnInner (backing new Deno.Command(...).output() and Deno.spawnAndWait) rejects stdin: "piped" with a TypeError before spawning. A piped stdin only makes sense when you can write to the child while it runs, which requires a live ChildProcess from spawn(); output()-style helpers only return after exit, so the pipe would be unusable.
Source
Thrown at ext/process/40_process.js:646
}
}
function spawnInner(command, {
args = [],
cwd = undefined,
clearEnv = false,
env = { __proto__: null },
uid = undefined,
gid = undefined,
signal = undefined,
stdin = "null",
stdout = "piped",
stderr = "piped",
windowsRawArguments = false,
[kNeedsNpmProcessState]: needsNpmProcessState = false,
} = { __proto__: null }) {
if (stdin === "piped") {
throw new TypeError(
"Piped stdin is not supported for this function, use 'Deno.Command().spawn()' instead",
);
}
// Bypass ChildProcess and ReadableStream machinery. Creating streams
// just to immediately collect all data has significant overhead that
// causes RSS growth in tight loops. Reading directly from the resource
// IDs avoids that overhead.
const child = op_spawn_child({
cmd: pathFromURL(command),
args: ArrayPrototypeMap(args, String),
cwd: pathFromURL(cwd),
clearEnv,
argv0: undefined,
env: ObjectEntries(env),
uid,
gid,
stdin,
stdout,View on GitHub (pinned to 9ad36f7a2c)
Solutions
- Switch to spawn(): const child = cmd.spawn(); then write to child.stdin.getWriter() and close it
- Change stdin to "inherit", "null", or omit it when the child needs no input
- For one-shot input, write input via child.stdin after spawn(), or use an OS-level pipe/stdin file instead of stdin: "piped" in output()
Example fix
// before
const out = await new Deno.Command("cat", { stdin: "piped" }).output(); // TypeError
// after
const child = new Deno.Command("cat", { stdin: "piped", stdout: "piped" }).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
const { stdin: _s, ...opts } = spawnOpts; // strip piped stdin
const out = await new Deno.Command(cmd, opts).output();
// or branch: if you need to write input, use spawn() instead Type guard
const needsStdin = (o: Deno.CommandOptions | undefined): boolean => o?.stdin === "piped";
Prevention
- Never share an options object containing stdin: "piped" with output()-style calls
- Branch on whether input must be written: spawn() + child.stdin, else output()
- Let TypeScript guide you: the output() result has no stdin handle, so piped stdin there is always a bug
When it happens
Trigger: new Deno.Command("cat", { stdin: "piped" }).output(), or Deno.spawnAndWait("cat", { stdin: "piped" }); also copying options objects built for spawn() straight into an output() call.
Common situations: Reusing one shared options object for both streaming and one-shot code paths; porting scripts that previously used Deno.run with customStdin; trying to feed input without knowing about spawn()+child.stdin.
Related errors
- Piped stdin is not supported for this function, use 'Deno.Co
- Cannot get 'stdout': 'stdout' is not piped
- Cannot get 'stderr': 'stderr' is not piped
- Illegal constructor
- Cannot collect output: 'stdout' is locked
AI-assisted analysis of denoland/deno@9ad36f7a2c (2026-08-20).
Data as JSON: /api/errors/e109c8386eeb3027.
Report an issue: GitHub.