# Is date-fns ESM-only? Can you require() it?

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

Modern JavaScript date utility library

Last verified Sep 9, 2026 against date-fns@4.4.0.

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

## What to do

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

## Facts

- 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

## Runtime test results for date-fns@4.4.0

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.0 | works | works |

## How to import date-fns

ES modules:

```js
import * as dateFns from "date-fns";
```

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

CommonJS:

```js
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") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "date-fns" works alongside it.

**Can I require date-fns?**

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

**Does date-fns work in Bun?**

Yes. import "date-fns" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

**Does date-fns ship TypeScript types?**

Yes. date-fns bundles its own type declarations; no @types package is needed.

## Links

- [date-fns on npm](https://www.npmjs.com/package/date-fns)
- [Source repository](https://github.com/date-fns/date-fns)
- [HTML version](https://canirequire.com/package/date-fns/)
- [JSON version](https://canirequire.com/package/date-fns.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.
