canirequire

canirequire › ESM-only › xo

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

JavaScript/TypeScript linter (ESLint wrapper) with great defaults

Last verified Sep 9, 2026 against xo@4.0.0. Markdown · JSON

ESM-only ESM-only since 0.41.0 — last CommonJS version is 0.40.3

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

Does xo@4.0.0 actually load? Runtime test results

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

Runtimerequire("xo")import "xo"
Node.js 18✗ failsERR_REQUIRE_ESM✗ failsSyntaxError
Node.js 20✗ failsERR_REQUIRE_ASYNC_MODULE✗ failsTypeError
Node.js 22✗ failsERR_REQUIRE_ASYNC_MODULE✓ works
Node.js 24✗ failsERR_REQUIRE_ASYNC_MODULE✓ works
Node.js 26✗ failsERR_REQUIRE_ASYNC_MODULE✓ works
Bun 1.4.0✗ failsTypeError✓ works

How to import xo

ES modules (import)

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 (require)

// 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, corrected where a runtime test of that version contradicted them (140 versions; the newest 60 shown).

VersionsFormatFirst published
0.41.0 – 4.0.0ESM-onlyJul 5, 2021
0.40.0 – 0.40.3CommonJSMay 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

Other esm-only packages

Similar popularity