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

> chai-as-promised@8.0.2 is ESM-only. ESM-only since 8.0.0 — last CommonJS version is 7.1.2.

Extends Chai with assertions about promises.

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

chai-as-promised dropped its CommonJS build in 8.0.0 (June 2024). The last version with a plain require()-able CommonJS entry is 7.1.2, published May 11, 2024.

On Node.js 20.19+, 22.12+ and newer, require("chai-as-promised") works with the latest version: Node.js loads synchronous ES modules through require(). Verified on Node.js 20, 22, 24 and 26. On Node.js 18, which has no require(esm), require("chai-as-promised") fails with ERR_REQUIRE_ESM.

## What to do

1. On Node.js 20.19+, 22.12+ and newer, require("chai-as-promised") works with the latest version: Node.js loads synchronous ES modules through require(). Verified on Node.js 20, 22, 24 and 26.
2. From a CommonJS file, use a dynamic import inside an async function: const chaiAsPromised = await import("chai-as-promised"). That works on every Node.js version the package supports.
3. If you need a synchronous require() or run Node.js 18: npm install chai-as-promised@7.1.2, the last CommonJS release (published May 11, 2024).
4. TypeScript: npm install -D @types/chai-as-promised

## Facts

- 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

## Runtime test results for chai-as-promised@8.0.2

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.

| Runtime | require("chai-as-promised") | import "chai-as-promised" |
|---|---|---|
| Node.js 18 | fails (ERR_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.0 | works | works |

## How to import chai-as-promised

ES modules:

```js
import * as chaiAsPromised from "chai-as-promised";
```

Namespace import shown because the ESM entry may have no default export; use named imports for what it exports.

CommonJS:

```js
// Node.js 20.19+, 22.12+ and newer (verified):
const chaiAsPromised = require("chai-as-promised");

// Any Node.js version the package supports, from an async function:
async function main() {
  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).

| Versions | Format | First published |
|---|---|---|
| 8.0.0 – 8.0.2 | ESM-only | Jun 9, 2024 |
| 1.0.0 – 7.1.2 | CommonJS | Mar 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 with a plain require()-able CommonJS entry 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?**

From a CommonJS file, use a dynamic import inside an async function: const chaiAsPromised = await import("chai-as-promised"). That works on every Node.js version the package supports. On Node.js 20.19+, 22.12+ and newer, require("chai-as-promised") works with the latest version: Node.js loads synchronous ES modules through require(). Verified on Node.js 20, 22, 24 and 26. 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.0 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

- [chai-as-promised on npm](https://www.npmjs.com/package/chai-as-promised)
- [Source repository](https://github.com/chaijs/chai-as-promised)
- [HTML version](https://canirequire.com/package/chai-as-promised/)
- [JSON version](https://canirequire.com/package/chai-as-promised.json)

---

For scripts and AI agents: any package is at https://canirequire.com/package/<name>/index.md (Markdown) or https://canirequire.com/package/<name>.json (JSON); the site index is https://canirequire.com/llms.txt. Fetch the URL directly; no search needed.
