canirequire

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

  1. require("ava") failed in our probe on Node.js 20+ as well; see the runtime table for the error before relying on it.
  2. 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).
  3. 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.
  4. 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.
  5. TypeScript: types are bundled; install nothing extra.
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
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.0

Module 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).

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

Similar popularity