Runtime
Bundler
Package Manager
Test Runner
Guides
Reference
Blog
Install Bun
Guides File System

Delete a file

The Bun.file() function accepts a path and returns a BunFile instance. Use the .delete() method to delete the file.

const path = "/path/to/file.txt";
const file = Bun.file(path);

await file.delete();

See Docs > API > File I/O for complete documentation of Bun.file().

On this page

No Headings