canirequire

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

  1. 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.
  2. TypeScript: npm install -D @types/y18n
Latest
5.0.8 (Apr 7, 2021)
Module format
Dual (CommonJS + ESM)
Last CommonJS version
5.0.8
Native ESM since
4.0.2
TypeScript types
@types/y18n
Node engines
>=10
Weekly downloads
126.1M
License
ISC

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.

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

VersionsFormatFirst published
5.0.0 – 5.0.8Dual (CommonJS + ESM)Sep 5, 2020
4.0.3CommonJSApr 7, 2021
4.0.2Dual (CommonJS + ESM)Apr 7, 2021
1.0.0 – 4.0.1CommonJSJul 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

Similar popularity