- Symptom
- TypeError: admin.firestore is not a functionTypeError: Cannot read properties of undefined (reading 'cert') from admin.credential.certadmin.apps is undefined in an initializeApp guard
- Cause
- firebase-admin 14.0.0 removed the legacy namespace API, so the default import no longer carries firestore(), auth(), messaging(), credential, or apps. It also dropped Node.js 18 and 20.
- Fix
- Switch to the modular entry points (firebase-admin/app, /firestore, /auth, /messaging) and run on Node.js 22 or later.
- Apply
import { initializeApp, getApps, cert } from 'firebase-admin/app'; import { getFirestore } from 'firebase-admin/firestore'; import { getAuth } from 'firebase-admin/auth'; const app = getApps()[0] ?? initializeApp({ credential: cert(serviceAccount) }); const db = getFirestore(app); const auth = getAuth(app);- Affected
- firebase-admin 14.0.0 and later (released 2026-06-08); requires Node.js 22+
- Sources
Last verified 2026-10-15 · Confirmed by 0 builders