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

> firebase@12.18.0 ships CommonJS and ESM builds, reachable only through subpaths. Dual package, subpaths only — require("firebase/…") works, require("firebase") does not.

Firebase JavaScript library for web and Node.js

Latest version 12.18.0, published Aug 19, 2026.

firebase exposes only subpaths in its exports map, for example "firebase/ai"; there is no root entry, so require("firebase") and import "firebase" both throw ERR_PACKAGE_PATH_NOT_EXPORTED. Each subpath ships a CommonJS and a native ESM build, so require("firebase/ai") and import "firebase/ai" both work.

## What to do

1. Load subpaths, never the bare name: const firebase = require("firebase/ai") or import from "firebase/ai". require("firebase") throws ERR_PACKAGE_PATH_NOT_EXPORTED.
2. TypeScript: types are bundled; install nothing extra.

## Facts

- Latest: 12.18.0 (Aug 19, 2026)
- Module format: Dual (CommonJS + ESM)
- Last CommonJS version: 12.18.0
- Native ESM since: 9.0.0
- TypeScript types: bundled
- Node engines: not declared
- Weekly downloads: 9.1M
- License: Apache-2.0

## Runtime test results for firebase@12.18.0

Runtime probe pending for this version (install failed: PROBE_TIMEOUT). The facts above come from package.json.

## How to import firebase

ES modules:

```js
import * as firebase from "firebase/ai";
```

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

CommonJS:

```js
const firebase = require("firebase/ai");
```

## Module format by version

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

| Versions | Format | First published |
|---|---|---|
| 10.7.2 – 12.18.0 | Dual (CommonJS + ESM) | Jan 18, 2024 |

## Frequently asked

**Is firebase ESM-only?**

firebase@12.18.0 ships CommonJS and ESM builds, reachable only through subpaths. firebase exposes only subpaths in its exports map, for example "firebase/ai"; there is no root entry, so require("firebase") and import "firebase" both throw ERR_PACKAGE_PATH_NOT_EXPORTED. Each subpath ships a CommonJS and a native ESM build, so require("firebase/ai") and import "firebase/ai" both work.

**Can I require firebase?**

Only by subpath. require("firebase") throws ERR_PACKAGE_PATH_NOT_EXPORTED because the exports map has no root entry; require("firebase/ai") works, and so does import from the same subpath.

**Does firebase ship TypeScript types?**

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

## Links

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