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

> babel-loader@10.1.1 is a CommonJS package. CommonJS — require() works on Node.js 20, 22, 24 and 26, fails on 18.

babel module loader for webpack

Last verified Sep 9, 2026 against babel-loader@10.1.1.

babel-loader ships CommonJS only. require("babel-loader") works on Node.js 20, 22, 24 and 26 but fails on Node.js 18 (ERR_REQUIRE_ESM). The package declares Node.js ^18.20.0 || ^20.10.0 || >=22.0.0. import "babel-loader" 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.

## What to do

1. require("babel-loader") works on Node.js 20, 22, 24 and 26 but fails on Node.js 18 (ERR_REQUIRE_ESM). The package declares Node.js ^18.20.0 || ^20.10.0 || >=22.0.0.
2. From ES modules use the default import: import babelLoader from "babel-loader"; then destructure. Named imports only work when Node.js can statically detect the exports.
3. TypeScript: no types are available for babel-loader; declare the module yourself if you need them.

## Facts

- Latest: 10.1.1 (Mar 9, 2026)
- Module format: CommonJS
- Last CommonJS version: 10.1.1
- TypeScript types: none
- Node engines: ^18.20.0 || ^20.10.0 || >=22.0.0
- Weekly downloads: 21.5M
- License: MIT

## Runtime test results for babel-loader@10.1.1

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

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

ES modules:

```js
import babelLoader from "babel-loader";
```

CommonJS:

```js
const babelLoader = require("babel-loader");
```

## Module format by version

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

| Versions | Format | First published |
|---|---|---|
| 5.3.1 – 10.1.1 | CommonJS | Jul 4, 2015 |

## Frequently asked

**Is babel-loader ESM-only?**

babel-loader@10.1.1 is a CommonJS package. babel-loader ships CommonJS only. require("babel-loader") works on Node.js 20, 22, 24 and 26 but fails on Node.js 18 (ERR_REQUIRE_ESM). The package declares Node.js ^18.20.0 || ^20.10.0 || >=22.0.0. import "babel-loader" 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 babel-loader with ES module syntax?**

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

Yes. import "babel-loader" loaded successfully in Bun 1.4.0 on Sep 9, 2026.

**Does babel-loader ship TypeScript types?**

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

## Links

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