canirequire › Dual (CommonJS + ESM) › y18n
Is y18n ESM-only? Can you require() it?
the bare-bones internationalization library used by yargs
Last verified Sep 9, 2026 against y18n@5.0.8. Markdown · JSON
Dual (CommonJS + ESM) Dual package — require() works on every Node.js version we test; import works too
y18n publishes both a CommonJS entry and a native ESM entry (ESM added in 4.0.2). require("y18n") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=10. import "y18n" works alongside it.
What to do
- Nothing to change. require("y18n") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=10. import * as y18n from "y18n" works alongside it; use named imports for what the ESM entry exports.
- TypeScript: npm install -D @types/y18n
Does y18n@5.0.8 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("y18n") from a CommonJS file and import "y18n" from an ES module.
| Runtime | require("y18n") | import "y18n" |
|---|---|---|
| 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 y18n
ES modules (import)
import * as y18n from "y18n";Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.
CommonJS (require)
const y18n = require("y18n");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 (21 versions; the newest 21 shown).
| Versions | Format | First published |
|---|---|---|
| 5.0.0 – 5.0.8 | Dual (CommonJS + ESM) | Sep 5, 2020 |
| 4.0.3 | CommonJS | Apr 7, 2021 |
| 4.0.2 | Dual (CommonJS + ESM) | Apr 7, 2021 |
| 1.0.0 – 4.0.1 | CommonJS | Jul 27, 2015 |
Frequently asked
Is y18n ESM-only?
y18n@5.0.8 ships CommonJS and ESM builds. y18n publishes both a CommonJS entry and a native ESM entry (ESM added in 4.0.2). require("y18n") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=10. import "y18n" works alongside it.
Can I require y18n?
Yes. y18n ships a CommonJS entry alongside the native ESM entry. require("y18n") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. The package declares Node.js >=10.
Does y18n work in Bun?
Yes. import "y18n" loaded successfully in Bun 1.4.0 on Sep 9, 2026.
Does y18n ship TypeScript types?
Not bundled. Install the community types with "npm install -D @types/y18n".
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
- @typescript-eslint/types 8.70.0CommonJS
- content-disposition 3.0.0ESM-only
- gensync 1.0.0-beta.2CommonJS
- send 1.2.1CommonJS
- path-scurry 2.0.2Dual
- acorn-jsx 5.3.2CommonJS
- natural-compare 1.4.0CommonJS
- @babel/compat-data 8.0.0CommonJS