canirequire

canirequireESM-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.

Latest
8.0.1 (May 17, 2026)
Module format
ESM-only
Last CommonJS version
7.0.0
ESM-only since
8.0.0 (Apr 27, 2026)
TypeScript types
Bundled
Node engines
^22.20 || ^24.12 || >=26
Weekly downloads
476K
License
MIT

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.

Runtimerequire("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.0

Module format by version

Derived from the type, main and exports fields of every stable release on npm (102 versions; the newest 60 shown).

VersionsFormatFirst published
8.0.0 – 8.0.1ESM-onlyApr 27, 2026
4.0.0 – 7.0.0Dual (CommonJS + ESM)Jan 3, 2022
1.3.1 – 3.15.0CommonJSMar 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

Similar popularity