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

> babel@6.23.0 declares a CommonJS entry, but require() fails at runtime. CommonJS on paper — require() failed in our runtime test.

Turn ES6 code into readable vanilla ES5 with source maps

Last verified Sep 9, 2026 against babel@6.23.0.

babel declares a CommonJS entry only, but require("babel") failed on every Node.js version in our probe: The node API for `babel` has been moved to `babel-core`. import "babel" resolves to the same file, so it fails the same way. That usually means a missing peer dependency, a browser-only global, or a package that is not meant to be loaded directly; see the runtime table below.

**Deprecated:** In 6.x, the babel package has been deprecated in favor of babel-cli. Check https://opencollective.com/babel to support the Babel maintainers

## What to do

1. require("babel") failed in our probe on every Node.js version (The node API for `babel` has been moved to `babel-core`); check the package README for peer dependencies or setup before relying on it.
2. From ES modules use the default import: import babel from "babel"; then destructure. Named imports only work when Node.js can statically detect the exports.
3. TypeScript: no types are available for babel; declare the module yourself if you need them.
4. This package is deprecated: In 6.x, the babel package has been deprecated in favor of babel-cli. Check https://opencollective.com/babel to support the Babel maintainers

## Facts

- Latest: 6.23.0 (Feb 13, 2017)
- Module format: CommonJS
- Last CommonJS version: 6.23.0
- TypeScript types: none
- Node engines: not declared
- Weekly downloads: 169K
- License: MIT

## Runtime test results for babel@6.23.0

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

| Runtime | require("babel") | import "babel" |
|---|---|---|
| Node.js 18 | fails (Error) | 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 babel

ES modules:

```js
import babel from "babel";
```

CommonJS:

```js
// require("babel") failed in our probe on every Node.js version we test (The node API for `babel` has been moved to `babel-core`); see the runtime table.
const babel = require("babel");
```

## Module format by version

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

| Versions | Format | First published |
|---|---|---|
| 5.5.2 – 6.23.0 | CommonJS | Jun 5, 2015 |

## Frequently asked

**Is babel ESM-only?**

babel@6.23.0 declares a CommonJS entry, but require() fails at runtime. babel declares a CommonJS entry only, but require("babel") failed on every Node.js version in our probe: The node API for `babel` has been moved to `babel-core`. import "babel" resolves to the same file, so it fails the same way. That usually means a missing peer dependency, a browser-only global, or a package that is not meant to be loaded directly; see the runtime table below.

**Can I require babel?**

Not in practice. babel declares a CommonJS entry, but require("babel") failed on every Node.js version in our probe: The node API for `babel` has been moved to `babel-core`. Check the package README for peer dependencies or setup before relying on it.

**Can I import babel with ES module syntax?**

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

Importing babel failed in Bun 1.4.0 on Sep 9, 2026: error: The node API for `babel` has been moved to `babel-core`.

**Does babel ship TypeScript types?**

No. babel ships no type declarations and there is no @types package for it.

## Links

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