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
- Load subpaths, never the bare name: const firebase = require("firebase/ai") or import from "firebase/ai". require("firebase") throws ERR_PACKAGE_PATH_NOT_EXPORTED.
- TypeScript: types are bundled; install nothing extra.
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.
| Runtime | require("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.0 | pending | pending |
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).
| 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
Other dual (commonjs + esm) packages
- minimatch 10.2.6Dual
- brace-expansion 5.0.9Dual
- lru-cache 11.5.2Dual
- tslib 2.8.1Dual
- glob 13.0.6Dual
- eslint-visitor-keys 5.0.1Dual
- yallist 5.0.0Dual
- balanced-match 4.0.4Dual
Similar popularity
- js-beautify 2.0.3CommonJS
- webpack-node-externals 3.0.0CommonJS
- styled-components 6.5.3CommonJS
- polished 4.3.1CommonJS
- @babel/plugin-proposal-nullish-coalescing-operator 7.18.6CommonJS
- @commitlint/config-conventional 21.2.2ESM-only
- xlsx 0.18.5CommonJS
- update-notifier 7.3.1ESM-only