canirequire › Dual (CommonJS + ESM) › espree
Is espree ESM-only? Can you require() it?
An Esprima-compatible JavaScript parser built on Acorn
Last verified Sep 9, 2026 against espree@11.2.0. Markdown · JSON
Dual (CommonJS + ESM) Dual package — require() works on every Node.js version we test; import works too
espree publishes both a CommonJS entry and a native ESM entry (ESM added in 8.0.0). require("espree") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js ^20.19.0 || ^22.13.0 || >=24. import "espree" works alongside it.
What to do
- Nothing to change. require("espree") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js ^20.19.0 || ^22.13.0 || >=24. import * as espree from "espree" works alongside it; use named imports for what the ESM entry exports.
- TypeScript: types are bundled; install nothing extra.
Does espree@11.2.0 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("espree") from a CommonJS file and import "espree" from an ES module.
| Runtime | require("espree") | import "espree" |
|---|---|---|
| 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 espree
ES modules (import)
import * as espree from "espree";Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.
CommonJS (require)
const espree = require("espree");Module format by version
Derived from the type, main and exports fields of every stable release on npm, corrected where a runtime test of that version contradicted them (94 versions; the newest 60 shown).
| Versions | Format | First published |
|---|---|---|
| 8.0.0 – 11.2.0 | Dual (CommonJS + ESM) | Jun 30, 2021 |
| 3.1.1 – 7.3.1 | CommonJS | Feb 26, 2016 |
Frequently asked
Is espree ESM-only?
espree@11.2.0 ships CommonJS and ESM builds. espree publishes both a CommonJS entry and a native ESM entry (ESM added in 8.0.0). require("espree") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js ^20.19.0 || ^22.13.0 || >=24. import "espree" works alongside it.
Can I require espree?
Yes. espree ships a CommonJS entry alongside the native ESM entry. require("espree") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js ^20.19.0 || ^22.13.0 || >=24.
Does espree work in Bun?
Yes. import "espree" loaded successfully in Bun 1.4.0 on Sep 9, 2026.
Does espree ship TypeScript types?
Yes. espree bundles its own type declarations; no @types package is needed.
Links
Other dual (commonjs + esm) packages
- minimatch 10.2.6Dual
- brace-expansion 5.0.9Dual
- lru-cache 11.5.2Dual
- tslib 2.8.1Dual
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
Similar popularity
- fill-range 7.1.1CommonJS
- jose 6.2.12ESM-only
- ajv-formats 3.0.1CommonJS
- @vitest/pretty-format 5.0.0ESM-only
- cosmiconfig 10.0.1CommonJS
- lightningcss-linux-x64-gnu 1.33.0CommonJS
- strip-final-newline 4.0.0ESM-only
- prettier 3.9.6Dual