Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

firebase admin: Named export 'firestore' not found

Open
#2,414 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript, node.js, vite
Domain
backend, databases

Research direction

Start with src/lib/firebase/database.server.js and the firebase.server and database.server entry points shown in the report, then reproduce the route navigation with the listed Firebase SDK, Node.js, and SvelteKit environment. Compare the firebase-admin import with the Vite SSR error and verify that affected routes load without the named-export failure.

Written by the indexing model from the issue text.

Description

api: firestore needs-triage

Unsure if this is a Firebase or sveltekit error

[REQUIRED] Step 2: Describe your environment
  • Operating System version: _____Fedora Silverblue 39 [toolbox]
  • Firebase SDK version: _____12.0.0
  • Firebase Product: Firestore
  • Node.js version: _____20.10.0
  • NPM version: _____10.2.3
  • Framework_____Sveltekit
[REQUIRED] Step 3: Describe the problem

When navigating to any route that calls firebase receiving this error

Named export 'firestore' not found. The requested module 'firebase-admin' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export

import pkg from 'firebase-admin';
const {firestore} = pkg;

at analyzeImportedModDifference (file:///var/home/dg/devs/sveltefire/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:50598:19)
at nodeImport (file:///var/home/dg/devs/sveltefire/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:50549:9)
at async ssrImport (file:///var/home/dg/devs/sveltefire/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:50444:24)
at async eval (/var/home/dg/devs/sveltefire/src/lib/firebase/database.server.js:4:31)
at async instantiateModule (file:///var/home/dg/devs/sveltefire/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:50506:9
Steps to reproduce:

Has been working perfectly up until yesterday.
The problem began yesterday
This morning I rebuilt using the latest packages, but the problem still persists
Created another toolbox with a fresh install of node (same version as the previous one

What happened? How can we make the problem occur?
This could be a description, log/console output, etc.

Relevant Code:

//firebase.server
import admin from 'firebase-admin';
import serviceAccount from '/src/lib/firebase/firebase-secrets.server.json';

if (admin.apps.length === 0) {
admin.initializeApp({
// @ts-ignore
credential: admin.credential.cert(serviceAccount)
});
}

export const db = admin.firestore();
export const auth = admin.auth();
export const storage = admin.storage();

//firebase.client
import { getAnalytics } from 'firebase/analytics';
import { getApps, initializeApp } from 'firebase/app';
import { getFirestore } from 'firebase/firestore';
import {
PUBLIC_API_KEY,
PUBLIC_AUTH_DOMAIN,
PUBLIC_PROJECT_ID,
PUBLIC_STORAGE_BUCKET,
PUBLIC_MESSAGING_SENDER_ID,
PUBLIC_API_ID,
PUBLIC_MEASUREMENT_ID
} from '$env/static/public';
import { is_client } from 'svelte/internal';

const firebaseConfig = {
apiKey: PUBLIC_API_KEY,
authDomain: PUBLIC_AUTH_DOMAIN,
projectId: PUBLIC_PROJECT_ID,
storageBucket: PUBLIC_STORAGE_BUCKET,
messagingSenderId: PUBLIC_MESSAGING_SENDER_ID,
appId: PUBLIC_API_ID,
measurementId: PUBLIC_MEASUREMENT_ID
};
if (getApps().length === 0) {
const app = initializeApp(firebaseConfig);
if (is_client) {
getAnalytics(app);
}
}
console.log('firebase was initialized');
export const db = getFirestore();

// database.server
//hte first line is casing the error
import { firestore } from 'firebase-admin';
import { db } from '$lib/firebase/firebase.server';
import { saveFileToBucket } from './firestorage.server';

//database.client
mport { setDoc, collection, doc } from 'firebase/firestore';
import { db } from './firebase.client';

/**

  • @param {string | undefined} userId
    */
    export async function setUser(userId) {
    const users = collection(db, 'users');
    await setDoc(doc(users, userId), {
    user_id: userId
    });
    }
Dominant language
TypeScript
Stars
1.7k
Forks
419
Avg merge
4d 20h
Merged PRs (30d)
16

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from firebase/firebase-admin-node

All issues in firebase/firebase-admin-node

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.