canirequire

canirequire › Dual (CommonJS + ESM) › firebase

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

Firebase JavaScript library for web and Node.js

Latest version 12.18.0, published Aug 19, 2026. Markdown · JSON

Dual (CommonJS + ESM) Dual package, subpaths only — require("firebase/…") works, require("firebase") does not

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

Does firebase@12.18.0 actually load? Runtime test results

Runtime probe pending for this version. The values below are what package.json declares; they are refreshed once the probe runs.

Runtimerequire("firebase")import "firebase"
Node.js 18✓ expected✓ expected
Node.js 20✓ expected✓ expected
Node.js 22✓ expected✓ expected
Node.js 24✓ expected✓ expected
Node.js 26✓ expected✓ expected
Bun 1.4.0pendingpending

Install failed in our sandbox: PROBE_TIMEOUT The rows above show what package.json declares.

How to import firebase

ES modules (import)

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

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

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 (473 versions; the newest 60 shown).

VersionsFormatFirst published
10.7.2 – 12.18.0Dual (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

Other dual (commonjs + esm) packages

Similar popularity