# Is y18n ESM-only? Can you require() it?

> y18n@5.0.8 ships CommonJS and ESM builds. Dual package — require() works on every Node.js version we test; import works too.

the bare-bones internationalization library used by yargs

Last verified Sep 9, 2026 against y18n@5.0.8.

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

## Facts

- 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

## Runtime test results for y18n@5.0.8

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:

```js
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:

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

- [y18n on npm](https://www.npmjs.com/package/y18n)
- [Source repository](https://github.com/yargs/y18n)
- [HTML version](https://canirequire.com/package/y18n/)
- [JSON version](https://canirequire.com/package/y18n.json)

---

For scripts and AI agents: any package is at https://canirequire.com/package/<name>/index.md (Markdown) or https://canirequire.com/package/<name>.json (JSON); the site index is https://canirequire.com/llms.txt. Fetch the URL directly; no search needed.
