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. 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 you can require() on every Node.js version, including 18 and older, is 7.0.0, published Feb 27, 2026.
require("ava") failed in our probe on Node.js 20+ as well. See the runtime matrix below for the exact error.
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.
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: The ‘ava’ module can only be imported in test files |
| Node.js 20 | ✗ failsError: The ‘ava’ module can only be imported in test files | ✗ failsError: The ‘ava’ module can only be imported in test files |
| Node.js 22 | ✗ failsError: The ‘ava’ module can only be imported in test files | ✗ failsError: The ‘ava’ module can only be imported in test files |
| Node.js 24 | ✗ failsError: The ‘ava’ module can only be imported in test files | ✗ failsError: The ‘ava’ module can only be imported in test files |
| Node.js 26 | ✗ failsError: The ‘ava’ module can only be imported in test files | ✗ failsError: The ‘ava’ module can only be imported in test files |
| Bun 1.4 | ✗ failsTest files must be run with the AVA CLI: | ✗ failsTest files must be run with the AVA CLI: |
How to import ava
ES modules (import)
import ava from "ava";CommonJS (require)
// Node.js 20.19+ / 22.12+ / newer (package has no top-level await):
const ava = require("ava");
// Any Node.js version:
const ava = await import("ava");
// Or pin the last CommonJS release:
// npm install ava@7.0.0Module format by version
Derived from the type, main and exports fields of every stable release on npm (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 you can require() on every Node.js version, including 18 and older, is 7.0.0, published Feb 27, 2026.
Which version of ava still supports CommonJS / require()?
7.0.0 is the last version of ava with a CommonJS build. 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?
Use a dynamic import: const mod = await import("ava"). On Node.js 20.19+, 22.12+ and newer, a plain require("ava") also works for ESM packages that do not use top-level await. Alternatively pin ava@7.0.0.
Does ava work in Bun?
Importing ava failed in Bun 1.4 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 - 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
- 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