Bun Delete a file

Delete a file

jarle Updated

File contents

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

jarle/bun-skills/tree/main/skills/bun-guides-write-file-unlink commit 5995574a2b

Frequently asked questions

npx skillmds@latest add jarle/bun-delete-a-file