canirequire › ESM-only › ava
Is ava ESM-only? Can you require() it?
Node.js test runner that lets you develop with confidence.
Last verified Sep 9, 2026 against ava@8.0.1. Markdown · JSON
ESM-only ESM-only since 8.0.0 — last CommonJS version is 7.0.0
ava dropped its CommonJS build in 8.0.0 (April 2026). The last version with a plain require()-able CommonJS entry is 7.0.0, published Feb 27, 2026; it declares support for Node.js ^20.19 || ^22.20 || ^24.12 || >=25.
require("ava") failed in our probe on Node.js 20+ as well; see the runtime table for the error before relying on it. Node.js 18 has no require(esm), and ava@8.0.1 declares Node.js ^22.20 || ^24.12 || >=26, so 18 is outside its supported range anyway.
ava@8.0.1 declares engines "^22.20 || ^24.12 || >=26", so Node.js 18, 20 are outside its supported range regardless of module format.
What to do
- require("ava") failed in our probe on Node.js 20+ as well; see the runtime table for the error before relying on it.
- From a CommonJS file, use a dynamic import inside an async function: const ava = await import("ava"). That works on every Node.js version the package supports (^22.20 || ^24.12 || >=26).
- If you need a synchronous require(): npm install ava@7.0.0, the last CommonJS release (published Feb 27, 2026); it declares Node.js ^20.19 || ^22.20 || ^24.12 || >=25.
- ava@8.0.1 declares engines "^22.20 || ^24.12 || >=26", so Node.js 18, 20 are unsupported regardless: upgrade Node.js or pin an older release.
- TypeScript: types are bundled; install nothing extra.
Does ava@8.0.1 actually load? Runtime test results
Installed and executed on Sep 9, 2026 with require("ava") from a CommonJS file and import "ava" from an ES module.
| Runtime | require("ava") | import "ava" |
|---|---|---|
| Node.js 18 | ✗ failsERR_REQUIRE_ESM | ✗ failsError |
| Node.js 20 | ✗ failsError | ✗ failsError |
| Node.js 22 | ✗ failsError | ✗ failsError |
| Node.js 24 | ✗ failsError | ✗ failsError |
| Node.js 26 | ✗ failsError | ✗ failsError |
| Bun 1.4.0 | ✗ failsError | ✗ failsError |
How to import ava
ES modules (import)
import * as ava from "ava";Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.
CommonJS (require)
// require("ava") failed in our probe on Node.js 22.12+ and newer as well (The ‘ava’ module can only be imported in test files); see the runtime table.
// Any Node.js version the package supports (^22.20 || ^24.12 || >=26), from an async function:
async function main() {
const ava = await import("ava");
}
// Or pin the last CommonJS release (declares Node.js ^20.19 || ^22.20 || ^24.12 || >=25):
// npm install ava@7.0.0Module 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 (102 versions; the newest 60 shown).
| Versions | Format | First published |
|---|---|---|
| 8.0.0 – 8.0.1 | ESM-only | Apr 27, 2026 |
| 4.0.0 – 7.0.0 | Dual (CommonJS + ESM) | Jan 3, 2022 |
| 1.3.1 – 3.15.0 | CommonJS | Mar 5, 2019 |
Frequently asked
Is ava ESM-only?
ava@8.0.1 is ESM-only. ava dropped its CommonJS build in 8.0.0 (April 2026). The last version with a plain require()-able CommonJS entry is 7.0.0, published Feb 27, 2026; it declares support for Node.js ^20.19 || ^22.20 || ^24.12 || >=25.
Which version of ava still supports CommonJS / require()?
7.0.0 is the last version of ava with a CommonJS build; it declares Node.js ^20.19 || ^22.20 || ^24.12 || >=25. Install it with "npm install ava@7.0.0". Every version from 8.0.0 on is ESM-only.
How do I use ava from a CommonJS file?
From a CommonJS file, use a dynamic import inside an async function: const ava = await import("ava"). That works on every Node.js version the package supports (^22.20 || ^24.12 || >=26). require("ava") failed in our probe on Node.js 20+ as well; see the runtime table for the error before relying on it. Alternatively pin ava@7.0.0 (declares Node.js ^20.19 || ^22.20 || ^24.12 || >=25).
Does ava work in Bun?
Importing ava failed in Bun 1.4.0 on Sep 9, 2026: Test files must be run with the AVA CLI:
Does ava ship TypeScript types?
Yes. ava 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
- babel-preset-stage-3 6.24.1CommonJS
- gulp-replace 1.1.4CommonJS
- eslint-config-google 0.14.0CommonJS
- babel-preset-flow 6.23.0CommonJS
- babel-preset-stage-2 6.24.1CommonJS
- tsd 0.33.0CommonJS
- karma-webpack 5.0.1CommonJS
- karma-coverage-istanbul-reporter 3.0.3CommonJS