# make-empty-dir

> Ensures that a directory is empty

Latest version **4.0.0** (published 2026-03-11) · MIT license · 0 weekly downloads

## Install

```sh
npm install make-empty-dir
pnpm add make-empty-dir
yarn add make-empty-dir
bun add make-empty-dir
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2026-03-11 |
| First published | 2020-04-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Node | >=22.13 |
| Dependencies | 1 |
| Unpacked size | 4.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 104 |
| Author | Zoltan Kochan |
| Maintainers | zkochan |
| Keywords | directory, folder, mkdir, make-dir, empty |

## Links

- npm: https://www.npmjs.com/package/make-empty-dir
- Repository: https://github.com/zkochan/packages/tree/main/make-empty-dir
- Homepage: https://github.com/zkochan/packages/tree/main/make-empty-dir#readme
- npm.io page: https://npm.io/package/make-empty-dir

## Dependencies (1)

- [@zkochan/rimraf](https://npm.io/package/@zkochan/rimraf.md) ^4.0.0

## Recent versions

- 4.0.0 (latest) — 2026-03-11
- 1.1.0 (next) — 2021-02-11
- 3.0.2 — 2024-07-04
- 3.0.1 — 2024-07-04
- 3.0.0 — 2024-07-04
- 2.1.0 — 2023-08-19
- 2.0.0 — 2021-04-11
- 1.0.0 — 2020-04-25

## README

# make-empty-dir

> Ensures that a directory is empty

[![npm version](https://img.shields.io/npm/v/make-empty-dir.svg)](https://www.npmjs.com/package/make-empty-dir)

Ensures that a directory is empty. Deletes directory contents if the directory is not empty. If the directory does not exist, it is created. The directory itself is not deleted.

It works faster than `emptyDir()` of `fs-extra` because the contents of the directory are not read before the creation of the directory.

## Installation

```sh
<npm|yarn|pnpm> add make-empty-dir
```

## Usage

```js
'use strict'
const makeEmptyDir = require('make-empty-dir')

await makeEmptyDir('dir-name')

// or create the parent dir as well
await makeEmptyDir('dir/subdir', { recursive: true })
```

## API

### `makeEmptyDir(dir: string, [opts]): Promise<'created' | 'emptied'>`

**Arguments:**

* `dir` - *Path* - the path of the directory.
* `opts.recursive` - *Boolean* - Optional. If true, parent directories will be created.

**Returns:**

A string is returned.

* `'created'` - if there was no directory
* `'emptied'` - if there was a directory and the its contents were removed.

## License

[MIT](./LICENSE) © [Zoltan Kochan](https://www.kochan.io)

---
_Source: https://npm.io/package/make-empty-dir · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
