canirequire › Dual (CommonJS + ESM) › es-module-lexer
Is es-module-lexer ESM-only? Can you require() it?
Lexes ES modules returning their import/export metadata
Last verified Sep 9, 2026 against es-module-lexer@3.0.2. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
es-module-lexer publishes both a CommonJS entry and a native ESM entry (ESM added in 0.1.2). require("es-module-lexer") and import "es-module-lexer" both work on every supported Node.js version and in Bun.
Does es-module-lexer@3.0.2 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("es-module-lexer") from a CommonJS file and import "es-module-lexer" from an ES module.
| Runtime | require("es-module-lexer") | import "es-module-lexer" |
|---|---|---|
| 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 es-module-lexer
ES modules (import)
import esModuleLexer from "es-module-lexer";CommonJS (require)
const esModuleLexer = require("es-module-lexer");Module format by version
Derived from the type, main and exports fields of every stable release on npm (79 versions; the newest 60 shown).
| Versions | Format | First published |
|---|---|---|
| 0.7.0 – 3.0.2 | Dual (CommonJS + ESM) | Jul 5, 2021 |
| 0.3.17 – 0.6.0 | CommonJS | Feb 18, 2020 |
| 0.3.15 – 0.3.16 | Dual (CommonJS + ESM) | Feb 12, 2020 |
Frequently asked
Is es-module-lexer ESM-only?
es-module-lexer@3.0.2 ships CommonJS and ESM builds. es-module-lexer publishes both a CommonJS entry and a native ESM entry (ESM added in 0.1.2). require("es-module-lexer") and import "es-module-lexer" both work on every supported Node.js version and in Bun.
Can I require es-module-lexer?
Yes. es-module-lexer ships a CommonJS entry, so require("es-module-lexer") works on every Node.js version, alongside the native ESM entry for import.
Does es-module-lexer work in Bun?
Yes. import "es-module-lexer" loaded successfully in Bun 1.4 on Sep 9, 2026.
Does es-module-lexer ship TypeScript types?
Yes. es-module-lexer 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
- lightningcss-linux-x64-gnu 1.33.0CommonJS
- strip-final-newline 4.0.0ESM-only
- prettier 3.9.6Dual
- @opentelemetry/api-logs 0.222.0CommonJS
- mkdirp 3.0.1Dual
- ansi-escapes 7.3.0ESM-only
- merge-descriptors 2.0.0CommonJS
- is-plain-obj 4.1.0ESM-only