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
- require("unbuild") failed in our probe on Node.js 20+ as well; see the runtime table for the error before relying on it.
- 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.
- 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).
- TypeScript: types are bundled; install nothing extra.
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.
| Runtime | require("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.5Module 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).
| 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
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 - string-width 8.2.2last CJS
4.2.3 - ansi-regex 6.3.0last CJS
5.0.1 - escape-string-regexp 5.0.0last CJS
4.0.0
Similar popularity
- @storybook/manager-webpack5 6.5.16CommonJS
- gulp-postcss 10.0.0CommonJS
- tslint-config-prettier 1.18.0CommonJS
- karma-cli 2.0.0No entry
- ember-resolver 13.2.0No entry
- ember-cli 7.2.0CommonJS
- grunt-contrib-jshint 3.2.0CommonJS
- @babel/plugin-proposal-throw-expressions 8.0.1ESM-only