# Is flat-cache ESM-only? Can you require() it?

> flat-cache@6.1.23 ships CommonJS and ESM builds. Dual package — require() works on every Node.js version we test; import works too.

A simple key/value storage using files to persist the data

Last verified Sep 9, 2026 against flat-cache@6.1.23.

flat-cache publishes both a CommonJS entry and a native ESM entry (ESM added in 6.0.0). require("flat-cache") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "flat-cache" works alongside it.

## What to do

1. Nothing to change. require("flat-cache") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import * as flatCache from "flat-cache" works alongside it; use named imports for what the ESM entry exports.
2. TypeScript: types are bundled; install nothing extra.

## Facts

- Latest: 6.1.23 (Jun 27, 2026)
- Module format: Dual (CommonJS + ESM)
- Last CommonJS version: 6.1.23
- Native ESM since: 6.0.0
- TypeScript types: bundled
- Node engines: not declared
- Weekly downloads: 136.5M
- License: MIT

## Runtime test results for flat-cache@6.1.23

Installed and executed on Sep 9, 2026 with require("flat-cache") from a CommonJS file and import "flat-cache" from an ES module.

| Runtime | require("flat-cache") | import "flat-cache" |
|---|---|---|
| Node.js 18 | works | works |
| Node.js 20 | works | works |
| Node.js 22 | works | works |
| Node.js 24 | works | works |
| Node.js 26 | works | works |
| Bun 1.4.0 | works | works |

## How to import flat-cache

ES modules:

```js
import * as flatCache from "flat-cache";
```

Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.

CommonJS:

```js
const flatCache = require("flat-cache");
```

## Module format by version

Derived from the type, main and exports fields of every stable release on npm (52 versions; the newest 52 shown).

| Versions | Format | First published |
|---|---|---|
| 6.0.0 – 6.1.23 | Dual (CommonJS + ESM) | Sep 29, 2024 |
| 1.0.0 – 5.0.0 | CommonJS | Feb 26, 2015 |

## Frequently asked

**Is flat-cache ESM-only?**

flat-cache@6.1.23 ships CommonJS and ESM builds. flat-cache publishes both a CommonJS entry and a native ESM entry (ESM added in 6.0.0). require("flat-cache") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "flat-cache" works alongside it.

**Can I require flat-cache?**

Yes. flat-cache ships a CommonJS entry alongside the native ESM entry. require("flat-cache") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun.

**Does flat-cache work in Bun?**

Yes. import "flat-cache" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

**Does flat-cache ship TypeScript types?**

Yes. flat-cache bundles its own type declarations; no @types package is needed.

## Links

- [flat-cache on npm](https://www.npmjs.com/package/flat-cache)
- [Source repository](https://github.com/jaredwray/cacheable)
- [HTML version](https://canirequire.com/package/flat-cache/)
- [JSON version](https://canirequire.com/package/flat-cache.json)

---

For scripts and AI agents: any package is at https://canirequire.com/package/<name>/index.md (Markdown) or https://canirequire.com/package/<name>.json (JSON); the site index is https://canirequire.com/llms.txt. Fetch the URL directly; no search needed.
