canirequire

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

Latest
4.4.0 (May 29, 2026)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
4.4.0
Native ESM since
3.0.0
TypeScript types
Bundled
Node engines
not declared
Weekly downloads
65.7M
License
MIT

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.

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

VersionsFormatFirst published
3.0.0 – 4.4.0Dual (CommonJS + ESM)Dec 18, 2023
2.5.0 – 2.30.0CommonJSOct 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

Similar popularity