canirequire › ESM-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.
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.
| Runtime | require("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.2Module 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 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
- 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
- react-bootstrap 2.10.10CommonJS
- lerna 10.0.1ESM-only
- browserify 17.0.1CommonJS
- pretty-quick 4.2.2Dual
- @angular/language-service 22.1.5CommonJS
- vuedraggable 2.24.3CommonJS
- shx 0.4.0CommonJS
- rollup-plugin-postcss 4.0.2CommonJS