canirequire

canirequireESM-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. 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 you can require() on every Node.js version, including 18 and older, is 0.40.3, published Jun 21, 2021.

require("xo") fails even on Node.js 20.19+ / 22.12+ because the package uses top-level await, which require(esm) cannot load. Use import() instead.

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

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✗ failsTypeError✓ works

How to import xo

ES modules (import)

import xo from "xo";

CommonJS (require)

// Node.js 20.19+ / 22.12+ / newer (package has no top-level await):
const xo = require("xo");

// Any Node.js version:
const xo = await import("xo");

// Or pin the last CommonJS release:
// 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).

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 you can require() on every Node.js version, including 18 and older, is 0.40.3, published Jun 21, 2021.

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

0.40.3 is the last version of xo with a CommonJS build. 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?

Use a dynamic import: const mod = await import("xo"). On Node.js 20.19+, 22.12+ and newer, a plain require("xo") also works for ESM packages that do not use top-level await. Alternatively pin xo@0.40.3.

Does xo work in Bun?

Yes. import "xo" loaded successfully in Bun 1.4 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