# Is webidl-conversions ESM-only? Can you require() it?

> webidl-conversions@8.0.1 is a CommonJS package. CommonJS — require() works on Node.js 20, 22, 24 and 26, fails on 18.

Implements the WebIDL algorithms for converting to and from JavaScript values

Last verified Sep 9, 2026 against webidl-conversions@8.0.1.

webidl-conversions ships CommonJS only. require("webidl-conversions") works on Node.js 20, 22, 24 and 26 but fails on Node.js 18 (TypeError). The package declares Node.js >=20. import "webidl-conversions" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.

## What to do

1. require("webidl-conversions") works on Node.js 20, 22, 24 and 26 but fails on Node.js 18 (TypeError). The package declares Node.js >=20.
2. From ES modules use the default import: import webidlConversions from "webidl-conversions"; then destructure. Named imports only work when Node.js can statically detect the exports.
3. TypeScript: npm install -D @types/webidl-conversions

## Facts

- Latest: 8.0.1 (Jan 2, 2026)
- Module format: CommonJS
- Last CommonJS version: 8.0.1
- TypeScript types: @types/webidl-conversions
- Node engines: >=20
- Weekly downloads: 118.3M
- License: BSD-2-Clause

## Runtime test results for webidl-conversions@8.0.1

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

| Runtime | require("webidl-conversions") | import "webidl-conversions" |
|---|---|---|
| Node.js 18 | fails (TypeError) | fails (TypeError) |
| 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 webidl-conversions

ES modules:

```js
import webidlConversions from "webidl-conversions";
```

CommonJS:

```js
const webidlConversions = require("webidl-conversions");
```

## Module format by version

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

| Versions | Format | First published |
|---|---|---|
| 1.0.0 – 8.0.1 | CommonJS | Aug 15, 2014 |

## Frequently asked

**Is webidl-conversions ESM-only?**

webidl-conversions@8.0.1 is a CommonJS package. webidl-conversions ships CommonJS only. require("webidl-conversions") works on Node.js 20, 22, 24 and 26 but fails on Node.js 18 (TypeError). The package declares Node.js >=20. import "webidl-conversions" also works because Node.js and Bun can import CommonJS from ES modules, but only the default export is guaranteed; named imports depend on Node's static analysis of the module.

**Can I import webidl-conversions with ES module syntax?**

Yes. import webidlConversions from "webidl-conversions" works in Node.js and Bun because they support importing CommonJS modules. Named imports work only when Node.js can statically detect the exports.

**Does webidl-conversions work in Bun?**

Yes. import "webidl-conversions" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

**Does webidl-conversions ship TypeScript types?**

Not bundled. Install the community types with "npm install -D @types/webidl-conversions".

## Links

- [webidl-conversions on npm](https://www.npmjs.com/package/webidl-conversions)
- [Source repository](https://github.com/jsdom/webidl-conversions)
- [HTML version](https://canirequire.com/package/webidl-conversions/)
- [JSON version](https://canirequire.com/package/webidl-conversions.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.
