canirequire

canirequireDual (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.

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✓ 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).

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

Similar popularity