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

> unbuild@3.6.1 is ESM-only. ESM-only since 0.5.6 — last CommonJS version is 0.5.5.

A unified JavaScript build system

Last verified Sep 9, 2026 against unbuild@3.6.1.

unbuild dropped its CommonJS build in 0.5.6 (October 2021). The last version with a plain require()-able CommonJS entry is 0.5.5, published Sep 29, 2021.

require("unbuild") failed in our probe on Node.js 20+ as well; see the runtime table for the error before relying on it. On Node.js 18, which has no require(esm), require("unbuild") fails with ERR_REQUIRE_ESM.

## What to do

1. require("unbuild") failed in our probe on Node.js 20+ as well; see the runtime table for the error before relying on it.
2. From a CommonJS file, use a dynamic import inside an async function: const unbuild = await import("unbuild"). That works on every Node.js version the package supports.
3. If you need a synchronous require() or run Node.js 18: npm install unbuild@0.5.5, the last CommonJS release (published Sep 29, 2021).
4. TypeScript: types are bundled; install nothing extra.

## Facts

- Latest: 3.6.1 (Aug 15, 2025)
- Module format: ESM-only
- Last CommonJS version: 0.5.5
- ESM-only since: 0.5.6 (Oct 1, 2021)
- TypeScript types: bundled
- Node engines: not declared
- Weekly downloads: 219K
- License: MIT

## Runtime test results for unbuild@3.6.1

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

| Runtime | require("unbuild") | import "unbuild" |
|---|---|---|
| Node.js 18 | fails (ERR_REQUIRE_ESM) | fails (Error) |
| Node.js 20 | fails (Error) | fails (Error) |
| Node.js 22 | fails (Error) | fails (Error) |
| Node.js 24 | fails (Error) | fails (Error) |
| Node.js 26 | fails (Error) | fails (Error) |
| Bun 1.4.0 | fails (Error) | fails (Error) |

## How to import unbuild

ES modules:

```js
import * as unbuild from "unbuild";
```

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

CommonJS:

```js
// require("unbuild") failed in our probe on Node.js 20.19+, 22.12+ and newer as well (rollup-plugin-dts requires the TypeScript compiler API. The installed typescript@7.0.2 does not provide it, and the `@typescript/typescri…); see the runtime table.

// Any Node.js version the package supports, from an async function:
async function main() {
  const unbuild = await import("unbuild");
}

// Or pin the last CommonJS release:
// npm install unbuild@0.5.5
```

## Module format by version

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

| Versions | Format | First published |
|---|---|---|
| 0.5.8 – 3.6.1 | ESM-only | Oct 20, 2021 |

## Frequently asked

**Is unbuild ESM-only?**

unbuild@3.6.1 is ESM-only. unbuild dropped its CommonJS build in 0.5.6 (October 2021). The last version with a plain require()-able CommonJS entry is 0.5.5, published Sep 29, 2021.

**Which version of unbuild still supports CommonJS / require()?**

0.5.5 is the last version of unbuild with a CommonJS build. Install it with "npm install unbuild@0.5.5". Every version from 0.5.6 on is ESM-only.

**How do I use unbuild from a CommonJS file?**

From a CommonJS file, use a dynamic import inside an async function: const unbuild = await import("unbuild"). That works on every Node.js version the package supports. require("unbuild") failed in our probe on Node.js 20+ as well; see the runtime table for the error before relying on it. Alternatively pin unbuild@0.5.5.

**Does unbuild work in Bun?**

Importing unbuild failed in Bun 1.4.0 on Sep 9, 2026: error: rollup-plugin-dts requires the TypeScript compiler API. The installed typescript@7.0.2 does not provide it, and the `@typescript/typescript6` fallback is not installed.

**Does unbuild ship TypeScript types?**

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

## Links

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