Node.js 对 Firestore 的支持不起作用
Node.js support for Firestore not working
我在我的网络应用程序中使用 Nuxt/Firestore。但是,firebase sdk 中存在一个问题,在 Node.js 中使用时会导致 firestore 出现问题。此处描述了问题 - https://github.com/firebase/firebase-js-sdk/issues/221
然而,最近这个问题已经关闭了,但是,我仍然继续面临同样的问题。主要问题是 "Cannot find module 'grpc'" 或 'firestore is not a function'.
我创建了一个模拟这个问题的虚拟项目,可以在这里下载:https://github.com/msahajwani/nuxt-firestore
要重现该问题,请执行以下步骤:
下载 repo 并安装依赖项
在 ~/api/ 文件夹中,创建一个名为 config.js 的文件,然后在该文件中添加您的 firebase 配置,如下所示:
let config = { apiKey: 'xxx', authDomain: 'xxx', databaseURL: 'xxx', projectId: 'xxx', storageBucket: 'xxx', messagingSenderId: 'xxx' }
运行 应用使用 npm 运行 dev
您会注意到该应用程序将在 http://localhost:3000
处正确加载
主页有一个导航栏,link 到主页和顶部。如果单击 'Top' link,它将正确加载。这是因为它是客户端渲染。
现在尝试在浏览器中刷新或直接加载页面 http://localhost:3000/top。这将强制服务器端渲染,然后您将看到错误。这是我一直在纠结的问题。
非常感谢任何帮助。
抱歉造成混淆。 https://github.com/firebase/firebase-js-sdk/issues/221 was fixed just recently and will be included in the next Firebase release. You can monitor the release notes (https://firebase.google.com/support/release-notes/js) 看看它什么时候熄灭(可能是这个星期四)。
我在我的网络应用程序中使用 Nuxt/Firestore。但是,firebase sdk 中存在一个问题,在 Node.js 中使用时会导致 firestore 出现问题。此处描述了问题 - https://github.com/firebase/firebase-js-sdk/issues/221
然而,最近这个问题已经关闭了,但是,我仍然继续面临同样的问题。主要问题是 "Cannot find module 'grpc'" 或 'firestore is not a function'.
我创建了一个模拟这个问题的虚拟项目,可以在这里下载:https://github.com/msahajwani/nuxt-firestore
要重现该问题,请执行以下步骤:
下载 repo 并安装依赖项
在 ~/api/ 文件夹中,创建一个名为 config.js 的文件,然后在该文件中添加您的 firebase 配置,如下所示:
let config = { apiKey: 'xxx', authDomain: 'xxx', databaseURL: 'xxx', projectId: 'xxx', storageBucket: 'xxx', messagingSenderId: 'xxx' }
运行 应用使用 npm 运行 dev
您会注意到该应用程序将在 http://localhost:3000
处正确加载
主页有一个导航栏,link 到主页和顶部。如果单击 'Top' link,它将正确加载。这是因为它是客户端渲染。
现在尝试在浏览器中刷新或直接加载页面 http://localhost:3000/top。这将强制服务器端渲染,然后您将看到错误。这是我一直在纠结的问题。
非常感谢任何帮助。
抱歉造成混淆。 https://github.com/firebase/firebase-js-sdk/issues/221 was fixed just recently and will be included in the next Firebase release. You can monitor the release notes (https://firebase.google.com/support/release-notes/js) 看看它什么时候熄灭(可能是这个星期四)。