canirequire

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

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

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.

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

VersionsFormatFirst published
5.0.2 – 5.0.9Dual (CommonJS + ESM)Feb 12, 2026
3.0.0 – 4.0.1ESM-onlyOct 7, 2023
0.0.0 – 2.1.4CommonJSOct 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

Similar popularity