Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Module

x/deno/cli/dts/lib.deno.unstable.d.ts>Deno.spawn

A modern runtime for JavaScript and TypeScript.
Go to Latest
function Deno.spawn
Deprecated
Deprecated

Use the Deno.Command API instead.

Executes a subprocess, waiting for it to finish and collecting all of its output.

Will throw an error if stdin: "piped" is passed.

If options stdout or stderr are not set to "piped", accessing the corresponding field on SpawnOutput will throw a TypeError.

const { code, stdout, stderr } = await Deno.spawn(Deno.execPath(), {
args: [
"eval",
"console.log('hello'); console.error('world')",
],
});
console.assert(code === 0);
console.assert("hello\n" === new TextDecoder().decode(stdout));
console.assert("world\n" === new TextDecoder().decode(stderr));
import { Deno } from "https://deno.land/x/deno@v1.28.1/cli/dts/lib.deno.unstable.d.ts";
const { spawn } = Deno;

UNSTABLE: New API, yet to be vetted.

Parameters

command: string | URL
optional
options: SpawnOptions