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
- 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.
- 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).
- 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.
- xo@4.0.0 declares engines ">=22", so Node.js 18, 20 are unsupported regardless: upgrade Node.js or pin an older release.
- TypeScript: types are bundled; install nothing extra.
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.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.3Module 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).
| 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
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 - string-width 8.2.2last CJS
4.2.3 - ansi-regex 6.3.0last CJS
5.0.1 - escape-string-regexp 5.0.0last CJS
4.0.0
Similar popularity
- vinyl-buffer 1.0.1CommonJS
- rollup-plugin-node-builtins 2.1.2CommonJS
- rollup-plugin-replace 2.2.0CommonJS
- yeoman-test 11.8.2ESM-only
- gulp-watch 5.0.1CommonJS
- np 12.1.0No entry
- ember-data 5.9.1ESM-only
- vinyl-source-stream 2.0.0CommonJS