firebase admin: Named export 'firestore' not found
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 4/5
- 预计耗时
- 3-5 天
- 新手友好度
- 25/100
- Issue 类型
- 缺陷
- 描述清晰度
- 需要澄清
- 活跃度
- 停滞
- 技术栈
- javascript, node.js, vite
调研方向
从报告中列出的 src/lib/firebase/database.server.js 以及 firebase.server 和 database.server 入口点开始,然后使用所列出的 Firebase SDK、Node.js 和 SvelteKit 环境重现路由导航。将 firebase-admin 的 import 与 Vite SSR 错误进行比较,并验证受影响的路由能够加载且不会出现 named-export 失败。
由索引模型根据 Issue 内容生成。
描述
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
});
}
- 主要语言
- TypeScript
- 星标
- 1.7k
- 派生
- 419
- 平均合并
- 4 天 20 小时
- 30 天内合并 PR
- 16
环境准备
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
firebase/firebase-admin-node 的其他 Issue
-
难度 3/5 1-2 天 新手友好度 35/100
firebase/firebase-admin-node#3234 ·
维护者通常 1 天内回复
-
[email protected] stable dependency tree fails npm audit via Storage uuid and Firestore google-gax可能已有人在做 @lahirumaramba 于 19 天前认领。 未关闭
firebase/firebase-admin-node#3221 · 3 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
-
api: messaging
难度 3/5 1-2 天 新手友好度 70/100
firebase/firebase-admin-node#3215 ·
维护者通常 1 天内回复
-
api: messaging
难度 5/5 一周以上 新手友好度 28/100
firebase/firebase-admin-node#3214 ·
维护者通常 1 天内回复
-
[Firestore] Re-export functions from '@google-cloud/firestore/pipelines'可能重新可做 @jonathanedey 于 89 天前认领,目前没有进行中的 PR。 未关闭api: firestore type: feature request
firebase/firebase-admin-node#3183 · 1 条评论 · 已指派 1 人 ·
维护者通常 1 天内回复
查看 firebase/firebase-admin-node 的全部 Issue
相似的 Issue
-
bug
难度 1/5 1 小时以内 新手友好度 88/100
StabilityNexus/Fate-EVM-Frontend#153 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
code-yeongyu/oh-my-openagent#9039 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 84/100
Tencent/teamai-cli#862 ·
维护者通常 1 天内回复
-
bug good first issue hacktoberfest redis
难度 2/5 1-3 小时 新手友好度 88/100
libredb/libredb-studio#1164 ·
维护者通常 1 天内回复
-
flake
难度 2/5 1-3 小时 新手友好度 85/100
维护者通常 1 天内回复