canirequire

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

  1. 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.
  2. TypeScript: types are bundled; install nothing extra.
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.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).

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") 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

Similar popularity