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

> typechain@8.3.2 is a CommonJS package. CommonJS — require() works on every Node.js version we test.

🔌 TypeScript bindings for Ethereum smartcontracts

Last verified Sep 9, 2026 against typechain@8.3.2.

typechain ships CommonJS only. require("typechain") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "typechain" 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.

It also declares a "module" field, so bundlers such as webpack, Vite and esbuild pick up an ESM build for tree-shaking.

## What to do

1. require("typechain") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun.
2. From ES modules use the default import: import typechain from "typechain"; then destructure. Named imports only work when Node.js can statically detect the exports.
3. TypeScript: types are bundled; install nothing extra.

## Facts

- Latest: 8.3.2 (Oct 15, 2023)
- Module format: CommonJS
- Last CommonJS version: 8.3.2
- TypeScript types: bundled
- Node engines: not declared
- Weekly downloads: 295K
- License: MIT

## Runtime test results for typechain@8.3.2

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

| Runtime | require("typechain") | import "typechain" |
|---|---|---|
| Node.js 18 | works | 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 typechain

ES modules:

```js
import typechain from "typechain";
```

CommonJS:

```js
const typechain = require("typechain");
```

## Module format by version

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

| Versions | Format | First published |
|---|---|---|
| 0.2.4 – 8.3.2 | CommonJS | Jun 23, 2018 |

## Frequently asked

**Is typechain ESM-only?**

typechain@8.3.2 is a CommonJS package. typechain ships CommonJS only. require("typechain") works on every Node.js version we test (18, 20, 22, 24 and 26) and in Bun. import "typechain" 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 typechain with ES module syntax?**

Yes. import typechain from "typechain" 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 typechain work in Bun?**

Yes. import "typechain" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

**Does typechain ship TypeScript types?**

Yes. typechain bundles its own type declarations; no @types package is needed.

## Links

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