Files
bun.sh/docs/guides/write-file/unlink.md
Colin McDonnell 404b90badc Add ecosystem guides (#3847)
* Add ecosystem guides

* Update titles

* Rename stric

* Add unlink and fetch guides

* Add formdata guide

* Tweak title

* Moar
2023-07-31 12:20:23 -07:00

615 B

name
name
Delete a file

To synchronously delete a file with Bun, use the unlinkSync function from the node:fs module. (Currently, there is no Bun API for deleting files.)

import { unlinkSync } from "node:fs";

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

To remove a file asynchronously, use the unlink function from the node:fs/promises module.

import { unlink } from "node:fs/promises";

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