canirequire

canirequireESM-only › chai-as-promised

Is chai-as-promised ESM-only? Can you require() it?

Extends Chai with assertions about promises.

Last verified Sep 9, 2026 against chai-as-promised@8.0.2. JSON

ESM-only ESM-only since 8.0.0 — last CommonJS version is 7.1.2

chai-as-promised dropped its CommonJS build in 8.0.0 (June 2024). The last version you can require() on every Node.js version, including 18 and older, is 7.1.2, published May 11, 2024.

On Node.js 20.19+, 22.12+ and every newer release, require("chai-as-promised") works anyway: Node can load synchronous ES modules through require(). Verified on Node 20, 22, 24, 26. Node.js 18 and older still fail with ERR_REQUIRE_ESM.

Latest
8.0.2 (Aug 22, 2025)
Module format
ESM-only
Last CommonJS version
7.1.2
ESM-only since
8.0.0 (Jun 9, 2024)
TypeScript types
@types/chai-as-promised
Node engines
not declared
Weekly downloads
1.3M
License
MIT

Does chai-as-promised@8.0.2 actually load? Runtime test results

Installed and executed on Sep 9, 2026 with require("chai-as-promised") from a CommonJS file and import "chai-as-promised" from an ES module.

Runtimerequire("chai-as-promised")import "chai-as-promised"
Node.js 18✗ failsERR_REQUIRE_ESM✓ works
Node.js 20✓ works✓ works
Node.js 22✓ works✓ works
Node.js 24✓ works✓ works
Node.js 26✓ works✓ works
Bun 1.4✓ works✓ works

How to import chai-as-promised

ES modules (import)

import chaiAsPromised from "chai-as-promised";

CommonJS (require)

// Node.js 20.19+ / 22.12+ / newer (package has no top-level await):
const chaiAsPromised = require("chai-as-promised");

// Any Node.js version:
const chaiAsPromised = await import("chai-as-promised");

// Or pin the last CommonJS release:
// npm install chai-as-promised@7.1.2

Module format by version

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

VersionsFormatFirst published
8.0.0 – 8.0.2ESM-onlyJun 9, 2024
1.0.0 – 7.1.2CommonJSMar 29, 2012

Frequently asked

Is chai-as-promised ESM-only?

chai-as-promised@8.0.2 is ESM-only. chai-as-promised dropped its CommonJS build in 8.0.0 (June 2024). The last version you can require() on every Node.js version, including 18 and older, is 7.1.2, published May 11, 2024.

Which version of chai-as-promised still supports CommonJS / require()?

7.1.2 is the last version of chai-as-promised with a CommonJS build. Install it with "npm install chai-as-promised@7.1.2". Every version from 8.0.0 on is ESM-only.

How do I use chai-as-promised from a CommonJS file?

Use a dynamic import: const mod = await import("chai-as-promised"). On Node.js 20.19+, 22.12+ and newer, a plain require("chai-as-promised") also works for ESM packages that do not use top-level await. Alternatively pin chai-as-promised@7.1.2.

Does chai-as-promised work in Bun?

Yes. import "chai-as-promised" loaded successfully in Bun 1.4 on Sep 9, 2026.

Does chai-as-promised ship TypeScript types?

Not bundled. Install the community types with "npm install -D @types/chai-as-promised".

Links

Other esm-only packages

Similar popularity