canirequire

canirequireDual (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.

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

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.

Runtimerequire("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).

VersionsFormatFirst published
6.0.0 – 6.1.23Dual (CommonJS + ESM)Sep 29, 2024
1.0.0 – 5.0.0CommonJSFeb 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

Similar popularity