aboutsummaryrefslogtreecommitdiff
path: root/docs/guides/write-file/unlink.md
blob: ba0cbe8b1d361119b736d7be69490921a538b7ed (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
---
name: Delete a file
---

To synchronously delete a file with Bun, use the `unlinkSync` function from the [`node:fs`](https://nodejs.org/api/fs.html#fs_fs_unlink_path_callback) module. (Currently, there is no `Bun` API for deleting files.)

```ts
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`](https://nodejs.org/api/fs.html#fs_fspromises_unlink_path) module.

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

const path = "/path/to/file.txt";
await unlink(path);
```
ons'>-6/+7 2023-02-06Add types for node:console and node:perf_hooks (#1982)Gravatar Colin McDonnell 8-153/+1342 2023-02-06mark bindingGravatar Dylan Conway 1-0/+1 2023-02-06Fix URL of wasi-js (#1997)Gravatar Cheng Shao 2-3/+3 2023-02-05speed it up a little moreGravatar Jarred Sumner 4-119/+290 2023-02-05`substringSharingImpl` allocates, do not useGravatar Jarred Sumner 2-57/+27 2023-02-05Faster Buffer.toString("ascii")Gravatar Jarred Sumner 1-8/+35 2023-02-04Bump querystring-es3 (#1988)Gravatar Gaurish Sethia 2-9/+36 2023-02-04Add `isDeepStructEqual` to `node:util`Gravatar Jarred Sumner 1-2/+6 2023-02-03Fixes #1978Gravatar Jarred Sumner 1-3/+7 2023-02-03Implement os.cpus() for Linux (#1977)Gravatar Justin Whear 1-2/+138 2023-02-03Support passing `Date` to `Bun.sleep`Gravatar Jarred Sumner 3-3/+27 2023-02-03Add test for propagating exceptionGravatar Jarred Sumner 3-5/+28 2023-02-03Add missing crypto exportGravatar Jarred Sumner 2-16/+22 2023-02-03Introduce `await Bun.sleep(ms)`Gravatar Jarred Sumner 5-15/+110 2023-02-03Fix types for `Array.fromAsync`Gravatar Ashcon Partovi 1-1/+1 2023-02-03Fix/Update Typescript types (#1972)Gravatar Gaurish Sethia 2-168/+38 2023-02-03fix require("perf_hooks")Gravatar Jarred Sumner 1-0/+1 2023-02-03allow other ArrayBufferView in Buffer functionsGravatar Jarred Sumner 1-6/+6 2023-02-03Make it less flakyGravatar Jarred Sumner 1-1/+1 2023-02-03Run tests on pull requestsGravatar Ashcon Partovi 1-0/+7 2023-02-03Run tests on pushGravatar Ashcon Partovi 1-0/+7 2023-02-03anotherGravatar Dylan Conway 1-1/+1 2023-02-03integers overflowingGravatar Dylan Conway 1-1/+1 2023-02-03Attempt to debug annotations 2Gravatar Ashcon Partovi 1-4/+1 2023-02-03Attempt to debug annotationsGravatar Ashcon Partovi 1-0/+7 2023-02-03Fix console output in bun wiptestGravatar Ashcon Partovi 1-4/+3 2023-02-03Use GitHub action SDKGravatar Ashcon Partovi 4-10/+16