Skip to main content

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 Bun.file().

Translation © 2026 fanyi.dev · Original © 2026 the Bun project (LICENSE.md names no copyright holder) (MIT)