canirequire › Dual (CommonJS + ESM) › brace-expansion
Is brace-expansion ESM-only? Can you require() it?
Brace expansion as known from sh/bash
Last verified Sep 9, 2026 against brace-expansion@5.0.9. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
brace-expansion publishes both a CommonJS entry and a native ESM entry (ESM added in 3.0.0). require("brace-expansion") and import "brace-expansion" both work on every supported Node.js version and in Bun.
Does brace-expansion@5.0.9 actually load? Runtime test results
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 | ✓ works | ✓ works |
How to import brace-expansion
ES modules (import)
import braceExpansion from "brace-expansion";CommonJS (require)
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") and import "brace-expansion" both work on every supported Node.js version and in Bun.
Can I require brace-expansion?
Yes. brace-expansion ships a CommonJS entry, so require("brace-expansion") works on every Node.js version, alongside the native ESM entry for import.
Does brace-expansion work in Bun?
Yes. import "brace-expansion" loaded successfully in Bun 1.4 on Sep 9, 2026.
Does brace-expansion ship TypeScript types?
Yes. brace-expansion bundles its own type declarations; no @types package is needed.
Links
Other dual (commonjs + esm) packages
- minimatch 10.2.6Dual
- 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
- postcss 8.5.28Dual
Similar popularity
- minimatch 10.2.6Dual
- debug 4.4.3CommonJS
- semver 7.8.5CommonJS
- ms 2.1.3CommonJS
- ansi-styles 7.0.0ESM-only
- strip-ansi 7.2.0ESM-only
- commander 15.0.0ESM-only