# create-temp-directory

> Create an empty, unique directory in the current OS's temp directory

Latest version **2.5.0** (published 2026-06-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install create-temp-directory
pnpm add create-temp-directory
yarn add create-temp-directory
bun add create-temp-directory
```

## Health

**Score 60/100 (C)** — status: active.

Positive: has types; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 2.5.0 |
| Published | 2026-06-12 |
| First published | 2018-07-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=20 |
| Dependencies | 0 |
| Unpacked size | 10.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 5 |
| Maintainers | avi.vahl |

## Links

- npm: https://www.npmjs.com/package/create-temp-directory
- Repository: https://github.com/AviVahl/create-temp-directory
- Homepage: https://github.com/AviVahl/create-temp-directory#readme
- Issues: https://github.com/AviVahl/create-temp-directory/issues
- npm.io page: https://npm.io/package/create-temp-directory

## Recent versions

- 2.5.0 (latest) — 2026-06-12
- 2.4.0 — 2023-02-26
- 2.3.0 — 2023-02-13
- 2.2.0 — 2023-01-15
- 2.1.0 — 2023-01-15
- 2.0.0 — 2022-09-22
- 1.1.1 — 2019-11-25
- 1.1.0 — 2019-10-14
- 1.0.3 — 2019-10-14
- 1.0.2 — 2019-02-15
- 1.0.1 — 2018-07-29
- 1.0.0 — 2018-07-29

## README

# create-temp-directory

[![npm version](https://img.shields.io/npm/v/create-temp-directory.svg)](https://www.npmjs.com/package/create-temp-directory)
[![tests](https://github.com/AviVahl/create-temp-directory/actions/workflows/tests.yml/badge.svg)](https://github.com/AviVahl/create-temp-directory/actions/workflows/tests.yml)

Create an empty, unique directory in the current OS's temp directory.
It returns an absolute `path` and a `remove()` function. Useful for tests.

## Getting started

Install the library as a `devDependency` in an existing project:

```
npm i create-temp-directory --save-dev
```

## Example usage

```ts
import { createTempDirectory, ITempDirectory } from "create-temp-directory";

describe("test suite", () => {
  let tempDir: ITempDirectory;

  beforeEach(async () => {
    tempDir = await createTempDirectory();
  });
  afterEach(async () => {
    await tempDir.remove();
  });

  it("some test", () => {
    const tempFilePath = path.join(tempDir.path, "temp-file");
    // the rest of the test...
  });
});
```

_NOTE: The above example is written using TypeScript. In pure JavaScript, you do not need to import/use `ITempDirectory`._

## License

MIT

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