Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

firebase admin: Named export 'firestore' not found

Aperta
#2,414 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
25/100
Tipo di issue
Bug
Chiarezza
Da chiarire
Stato di attività
Ferma
Stack tecnologico
javascript, node.js, vite
Ambito
backend, databases

Direzione di ricerca

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.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

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
    });
    }
Lingua principale
TypeScript
Stelle
1.7k
Fork
419
Merge medio
4g 20h
PR unite (30g)
16

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di firebase/firebase-admin-node

Tutte le issue di firebase/firebase-admin-node

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.