canirequire › Dual (CommonJS + ESM) › date-fns
Is date-fns ESM-only? Can you require() it?
Modern JavaScript date utility library
Last verified Sep 9, 2026 against date-fns@4.4.0. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
date-fns publishes both a CommonJS entry and a native ESM entry (ESM added in 3.0.0). require("date-fns") and import "date-fns" both work on every supported Node.js version and in Bun.
Does date-fns@4.4.0 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("date-fns") from a CommonJS file and import "date-fns" from an ES module.
| Runtime | require("date-fns") | import "date-fns" |
|---|---|---|
| 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 date-fns
ES modules (import)
import dateFns from "date-fns";CommonJS (require)
const dateFns = require("date-fns");Module format by version
Derived from the type, main and exports fields of every stable release on npm (137 versions; the newest 60 shown).
| Versions | Format | First published |
|---|---|---|
| 3.0.0 – 4.4.0 | Dual (CommonJS + ESM) | Dec 18, 2023 |
| 2.5.0 – 2.30.0 | CommonJS | Oct 16, 2019 |
Frequently asked
Is date-fns ESM-only?
date-fns@4.4.0 ships CommonJS and ESM builds. date-fns publishes both a CommonJS entry and a native ESM entry (ESM added in 3.0.0). require("date-fns") and import "date-fns" both work on every supported Node.js version and in Bun.
Can I require date-fns?
Yes. date-fns ships a CommonJS entry, so require("date-fns") works on every Node.js version, alongside the native ESM entry for import.
Does date-fns work in Bun?
Yes. import "date-fns" loaded successfully in Bun 1.4 on Sep 9, 2026.
Does date-fns ship TypeScript types?
Yes. date-fns 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
- d3-time-format 4.1.0ESM-only
- safe-push-apply 1.0.0CommonJS
- shell-quote 1.10.0CommonJS
- d3-timer 3.0.1ESM-only
- jest-matcher-utils 30.5.1Dual
- loose-envify 1.4.0CommonJS
- dequal 2.0.3Dual
- object.values 1.2.1CommonJS