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. 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.
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.
| Runtime | require("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.3Module 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 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
- ansi-styles 7.0.0last CJS
5.2.0 - strip-ansi 7.2.0last CJS
6.0.1 - commander 15.0.0last CJS
14.0.3 - supports-color 11.0.0last CJS
8.1.1 - chalk 6.0.0last CJS
4.1.2 - tslib 2.8.1last CJS
2.5.2 - string-width 8.2.2last CJS
4.2.3 - ansi-regex 6.3.0last CJS
5.0.1
Similar popularity
- vinyl-buffer 1.0.1CommonJS
- rollup-plugin-node-builtins 2.1.2CommonJS
- rollup-plugin-replace 2.2.0CommonJS
- yeoman-test 11.8.2Dual
- gulp-watch 5.0.1CommonJS
- np 12.1.0ESM-only
- ember-data 5.9.1CommonJS
- vinyl-source-stream 2.0.0CommonJS