Skip to main content
Deno 2 is finally here 🎉️
Learn more
Module

x/deno/cli/tsc/dts/lib.deno.ns.d.ts>Deno.writeTextFile

A modern runtime for JavaScript and TypeScript.
Latest
function Deno.writeTextFile
allow-read
allow-write
import { Deno } from "https://deno.land/x/deno@v2.0.4/cli/tsc/dts/lib.deno.ns.d.ts";
const { writeTextFile } = Deno;

Write string data to the given path, by default creating a new file if needed, else overwriting.

await Deno.writeTextFile("hello1.txt", "Hello world\n");  // overwrite "hello1.txt" or create it

Requires allow-write permission, and allow-read if options.create is false.

Parameters

path: string | URL
data: string | ReadableStream<string>
optional
options: WriteFileOptions

Returns

Promise<void>