deno / 1.23.2 / ~ / deno.readtextfilesync.html /

Deno.readTextFileSync

Synchronously reads and returns the entire contents of a file as utf8 encoded string. Reading a directory throws an error.

const data = Deno.readTextFileSync("hello.txt");
console.log(data);

Requires allow-read permission.

function readTextFileSync( path: string | URL) : string;
readTextFileSync( path: string | URL) : string

Parameters

path: string | URL

Return Type

string