# Is brace-expansion ESM-only? Can you require() it?

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

Brace expansion as known from sh/bash

Last verified Sep 9, 2026 against brace-expansion@5.0.9.

brace-expansion publishes both a CommonJS entry and a native ESM entry (ESM added in 3.0.0). require("brace-expansion") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js 20 || >=22. import "brace-expansion" works alongside it.

## What to do

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

## Facts

- Latest: 5.0.9 (Jul 30, 2026)
- Module format: Dual (CommonJS + ESM)
- Last CommonJS version: 5.0.9
- Native ESM since: 3.0.0
- TypeScript types: bundled
- Node engines: 20 || >=22
- Weekly downloads: 536.9M
- License: MIT

## Runtime test results for brace-expansion@5.0.9

Installed and executed on Sep 9, 2026 with require("brace-expansion") from a CommonJS file and import "brace-expansion" from an ES module.

| Runtime | require("brace-expansion") | import "brace-expansion" |
|---|---|---|
| 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 brace-expansion

ES modules:

```js
import * as braceExpansion from "brace-expansion";
```

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

CommonJS:

```js
const braceExpansion = require("brace-expansion");
```

## Module format by version

Derived from the type, main and exports fields of every stable release on npm (48 versions; the newest 48 shown).

| Versions | Format | First published |
|---|---|---|
| 5.0.2 – 5.0.9 | Dual (CommonJS + ESM) | Feb 12, 2026 |
| 3.0.0 – 4.0.1 | ESM-only | Oct 7, 2023 |
| 0.0.0 – 2.1.4 | CommonJS | Oct 13, 2013 |

## Frequently asked

**Is brace-expansion ESM-only?**

brace-expansion@5.0.9 ships CommonJS and ESM builds. brace-expansion publishes both a CommonJS entry and a native ESM entry (ESM added in 3.0.0). require("brace-expansion") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js 20 || >=22. import "brace-expansion" works alongside it.

**Can I require brace-expansion?**

Yes. brace-expansion ships a CommonJS entry alongside the native ESM entry. require("brace-expansion") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js 20 || >=22.

**Does brace-expansion work in Bun?**

Yes. import "brace-expansion" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

**Does brace-expansion ship TypeScript types?**

Yes. brace-expansion bundles its own type declarations; no @types package is needed.

## Links

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