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. JSON
Dual (CommonJS + ESM) Dual package — both require() and import work
y18n publishes both a CommonJS entry and a native ESM entry (ESM added in 4.0.2). require("y18n") and import "y18n" both work on every supported Node.js version and in Bun.
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 | ✓ works | ✓ works |
How to import y18n
ES modules (import)
import y18n from "y18n";CommonJS (require)
const y18n = require("y18n");Module format by version
Derived from the type, main and exports fields of every stable release on npm (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") and import "y18n" both work on every supported Node.js version and in Bun.
Can I require y18n?
Yes. y18n ships a CommonJS entry, so require("y18n") works on every Node.js version, alongside the native ESM entry for import.
Does y18n work in Bun?
Yes. import "y18n" loaded successfully in Bun 1.4 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
- 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
- raw-body 4.0.0ESM-only
- 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
- http-proxy-agent 9.1.0ESM-only