canirequire

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

Latest
11.2.0 (Mar 6, 2026)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
11.2.0
Native ESM since
8.0.0
TypeScript types
Bundled
Node engines
^20.19.0 || ^22.13.0 || >=24
Weekly downloads
115.4M
License
BSD-2-Clause

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.

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

VersionsFormatFirst published
8.0.0 – 11.2.0Dual (CommonJS + ESM)Jun 30, 2021
3.1.1 – 7.3.1CommonJSFeb 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

Similar popularity