canirequire

canirequire › ESM-only › unbuild

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

A unified JavaScript build system

Last verified Sep 9, 2026 against unbuild@3.6.1. Markdown · JSON

ESM-only ESM-only since 0.5.6 — last CommonJS version is 0.5.5

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.
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

Does unbuild@3.6.1 actually load? Runtime test results

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

Runtimerequire("unbuild")import "unbuild"
Node.js 18✗ failsERR_REQUIRE_ESM✗ failsError
Node.js 20✗ failsError✗ failsError
Node.js 22✗ failsError✗ failsError
Node.js 24✗ failsError✗ failsError
Node.js 26✗ failsError✗ failsError
Bun 1.4.0✗ failsError✗ failsError

How to import unbuild

ES modules (import)

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 (require)

// 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, corrected where a runtime test of that version contradicted them (97 versions; the newest 60 shown).

VersionsFormatFirst published
0.5.8 – 3.6.1ESM-onlyOct 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

Other esm-only packages

Similar popularity