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. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
espree publishes both a CommonJS entry and a native ESM entry (ESM added in 8.0.0). require("espree") and import "espree" both work on every supported Node.js version and in Bun.
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 | ✓ works | ✓ works |
How to import espree
ES modules (import)
import espree from "espree";CommonJS (require)
const espree = require("espree");Module format by version
Derived from the type, main and exports fields of every stable release on npm (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") and import "espree" both work on every supported Node.js version and in Bun.
Can I require espree?
Yes. espree ships a CommonJS entry, so require("espree") works on every Node.js version, alongside the native ESM entry for import.
Does espree work in Bun?
Yes. import "espree" loaded successfully in Bun 1.4 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
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
- js-yaml 5.4.1Dual
Similar popularity
- tapable 2.3.3CommonJS
- fill-range 7.1.1CommonJS
- jose 6.2.12ESM-only
- ajv-formats 3.0.1CommonJS
- cosmiconfig 10.0.1CommonJS
- lightningcss-linux-x64-gnu 1.33.0CommonJS
- strip-final-newline 4.0.0ESM-only
- prettier 3.9.6Dual