canirequire › Dual (CommonJS + ESM) › flat-cache
Is flat-cache ESM-only? Can you require() it?
A simple key/value storage using files to persist the data
Last verified Sep 9, 2026 against flat-cache@6.1.23. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
flat-cache publishes both a CommonJS entry and a native ESM entry (ESM added in 6.0.0). require("flat-cache") and import "flat-cache" both work on every supported Node.js version and in Bun.
Does flat-cache@6.1.23 actually load? Runtime test results
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 | ✓ works | ✓ works |
How to import flat-cache
ES modules (import)
import flatCache from "flat-cache";CommonJS (require)
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") and import "flat-cache" both work on every supported Node.js version and in Bun.
Can I require flat-cache?
Yes. flat-cache ships a CommonJS entry, so require("flat-cache") works on every Node.js version, alongside the native ESM entry for import.
Does flat-cache work in Bun?
Yes. import "flat-cache" loaded successfully in Bun 1.4 on Sep 9, 2026.
Does flat-cache ship TypeScript types?
Yes. flat-cache bundles its own type declarations; no @types package is needed.
Links
Other dual (commonjs + esm) packages
- minimatch 10.2.6Dual
- brace-expansion 5.0.9Dual
- lru-cache 11.5.2Dual
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
- js-yaml 5.4.1Dual
Similar popularity
- callsites 4.2.0ESM-only
- strip-bom 5.0.0ESM-only
- eventemitter3 5.0.4Dual
- escalade 3.2.0Dual
- mime 4.1.0ESM-only
- flatted 3.4.4ESM-only
- call-bound 1.0.4CommonJS
- fast-glob 3.3.3CommonJS