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

> xo@4.0.0 is ESM-only. ESM-only since 0.41.0 — last CommonJS version is 0.40.3.

JavaScript/TypeScript linter (ESLint wrapper) with great defaults

Last verified Sep 9, 2026 against xo@4.0.0.

xo dropped its CommonJS build in 0.41.0 (July 2021). The last version with a plain require()-able CommonJS entry is 0.40.3, published Jun 21, 2021; it declares support for Node.js >=12.20.

require("xo") fails even on Node.js 22.12+ and newer: the package uses top-level await, which require(esm) cannot load (ERR_REQUIRE_ASYNC_MODULE). Use import() instead. Node.js 18 has no require(esm), and xo@4.0.0 declares Node.js >=22, so 18 is outside its supported range anyway.

xo@4.0.0 declares engines ">=22", so Node.js 18, 20 are outside its supported range regardless of module format.

## What to do

1. require("xo") fails even on Node.js 22.12+ and newer: the package uses top-level await, which require(esm) cannot load (ERR_REQUIRE_ASYNC_MODULE). Use import() instead.
2. From a CommonJS file, use a dynamic import inside an async function: const xo = await import("xo"). That works on every Node.js version the package supports (>=22).
3. If you need a synchronous require() or run Node.js 18: npm install xo@0.40.3, the last CommonJS release (published Jun 21, 2021); it declares Node.js >=12.20.
4. xo@4.0.0 declares engines ">=22", so Node.js 18, 20 are unsupported regardless: upgrade Node.js or pin an older release.
5. TypeScript: types are bundled; install nothing extra.

## Facts

- Latest: 4.0.0 (Jul 6, 2026)
- Module format: ESM-only
- Last CommonJS version: 0.40.3
- ESM-only since: 0.41.0 (Jul 5, 2021)
- TypeScript types: bundled
- Node engines: >=22
- Weekly downloads: 141K
- License: MIT

## Runtime test results for xo@4.0.0

Installed and executed on Sep 9, 2026 with require("xo") from a CommonJS file and import "xo" from an ES module.

| Runtime | require("xo") | import "xo" |
|---|---|---|
| Node.js 18 | fails (ERR_REQUIRE_ESM) | fails (SyntaxError) |
| Node.js 20 | fails (ERR_REQUIRE_ASYNC_MODULE) | fails (TypeError) |
| Node.js 22 | fails (ERR_REQUIRE_ASYNC_MODULE) | works |
| Node.js 24 | fails (ERR_REQUIRE_ASYNC_MODULE) | works |
| Node.js 26 | fails (ERR_REQUIRE_ASYNC_MODULE) | works |
| Bun 1.4.0 | fails (TypeError) | works |

## How to import xo

ES modules:

```js
import * as xo from "xo";
```

Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.

CommonJS:

```js
// Node.js 22.12+ and newer cannot require() this package: it uses top-level await.

// Any Node.js version the package supports (>=22), from an async function:
async function main() {
  const xo = await import("xo");
}

// Or pin the last CommonJS release (declares Node.js >=12.20):
// npm install xo@0.40.3
```

## Module format by version

Derived from the type, main and exports fields of every stable release on npm (140 versions; the newest 60 shown).

| Versions | Format | First published |
|---|---|---|
| 0.41.0 – 4.0.0 | ESM-only | Jul 5, 2021 |
| 0.40.0 – 0.40.3 | CommonJS | May 9, 2021 |

## Frequently asked

**Is xo ESM-only?**

xo@4.0.0 is ESM-only. xo dropped its CommonJS build in 0.41.0 (July 2021). The last version with a plain require()-able CommonJS entry is 0.40.3, published Jun 21, 2021; it declares support for Node.js >=12.20.

**Which version of xo still supports CommonJS / require()?**

0.40.3 is the last version of xo with a CommonJS build; it declares Node.js >=12.20. Install it with "npm install xo@0.40.3". Every version from 0.41.0 on is ESM-only.

**How do I use xo from a CommonJS file?**

From a CommonJS file, use a dynamic import inside an async function: const xo = await import("xo"). That works on every Node.js version the package supports (>=22). require("xo") fails even on Node.js 22.12+ and newer: the package uses top-level await, which require(esm) cannot load (ERR_REQUIRE_ASYNC_MODULE). Use import() instead. Alternatively pin xo@0.40.3 (declares Node.js >=12.20).

**Does xo work in Bun?**

Yes. import "xo" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

**Does xo ship TypeScript types?**

Yes. xo bundles its own type declarations; no @types package is needed.

## Links

- [xo on npm](https://www.npmjs.com/package/xo)
- [Source repository](https://github.com/xojs/xo)
- [HTML version](https://canirequire.com/package/xo/)
- [JSON version](https://canirequire.com/package/xo.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.
