Skip to content

How to Delete File with Deno

Last updated on December 5, 2022

In this tutorial, you will learn how to delete a file in Deno. And Deleting directories using Deno’s built-in functions.

For deleting a file or a directory using any of the functions below, you need to add the --allow-write flag.

Examples to delete files using Deno.

// async
await Deno.remove("./file.txt");
// sync
Deno.removeSync("./file.txt");

Examples to delete directories using Deno.

// delete empty folder
await Deno.remove("./dir_name");
// delete non-empty folder
await Deno.remove("./dir_name", { recursive: true });
// delete empty folder sync
Deno.removeSync("./dir_name");
// delete non-empty folder sync
Deno.removeSync("./dir_name", { recursive: true });

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments