我正在 Expo 中开发一个 RN 应用程序,以 firebase 作为后端。到目前为止,该应用程序仅使用 firebase auth 和 firestore,无论出于何种原因,我随机开始收到 ReferenceError: Can't find variable: IDBIndex
错误。我调整了我的 firebase 配置以适应 v9 标准,而不是使用 compat
包。我确保我的应用程序没有使用 Google Analytics。我还降级到 [email protected] ,与博览会文档相匹配和其他类似的帖子。
当应用程序运行时,我也将 git 恢复到应用程序的早期版本(具有早期的依赖项和代码),但仍然返回相同的错误。发生这种情况时,我完全重新安装了 node 和 npm,因为我认为这是发生这种情况的唯一可能的原因,但这也无济于事(得到相同的 IDB 错误)。我仍然认为这是一个与 firebase 相关的问题,但我几乎不知道它可能是什么。
这是我的 firebase 配置:
import { initializeApp } from 'firebase/app'
import { getAuth, connectAuthEmulator } from "firebase/auth";
import { getFirestore, connectFirestoreEmulator } from "firebase/firestore";
import {
FIREBASE_API_KEY,
FIREBASE_AUTH_DOMAIN,
FIREBASE_PROJECT_ID,
FIREBASE_STORAGE_BUCKET,
FIREBASE_MESSAGING_SENDER_ID,
FIREBASE_APP_ID,
FIREBASE_MEASUREMENT_ID,
} from '@env';
const firebaseConfig = {
apiKey: FIREBASE_API_KEY,
authDomain: FIREBASE_AUTH_DOMAIN,
projectId: FIREBASE_PROJECT_ID,
storageBucket: FIREBASE_STORAGE_BUCKET,
messagingSenderId: FIREBASE_MESSAGING_SENDER_ID,
appId: FIREBASE_APP_ID,
measurementId: FIREBASE_MEASUREMENT_ID,
};
const app = initializeApp(firebaseConfig);
export default app;
export const auth = getAuth(app);
export const firestore = getFirestore(app);
if (process.env.NODE_ENV === "development") {
connectAuthEmulator(auth, "http://localhost:9099");
connectFirestoreEmulator(firestore, "localhost", 8080);
}
如果您需要查看更多文件或需要了解更多详细信息,请告诉我。
I am developing a RN app in Expo with firebase as backend. So far, the app only uses firebase auth and firestore and for whatever reason, I randomly started getting the error of ReferenceError: Can't find variable: IDBIndex
. I adjusted my firebase config to suit the v9 standards instead of using the compat
package. I ensured my app was not using Google Analytics. I have also downgraded to [email protected] which matches up with the expo documentation and this other similar post.
I have also git reverted into previous versions of the app (with earlier dependencies and code) when it was working but still got back the same error. When this occurred, I entirely reinstalled node and npm because I thought that was the only other possible reason this could be happening but that was to no avail as well (getting the same IDB error). I still think this is a firebase related issue, but I am pretty much all out of ideas as to what it could be.
Here is my firebase config:
import { initializeApp } from 'firebase/app'
import { getAuth, connectAuthEmulator } from "firebase/auth";
import { getFirestore, connectFirestoreEmulator } from "firebase/firestore";
import {
FIREBASE_API_KEY,
FIREBASE_AUTH_DOMAIN,
FIREBASE_PROJECT_ID,
FIREBASE_STORAGE_BUCKET,
FIREBASE_MESSAGING_SENDER_ID,
FIREBASE_APP_ID,
FIREBASE_MEASUREMENT_ID,
} from '@env';
const firebaseConfig = {
apiKey: FIREBASE_API_KEY,
authDomain: FIREBASE_AUTH_DOMAIN,
projectId: FIREBASE_PROJECT_ID,
storageBucket: FIREBASE_STORAGE_BUCKET,
messagingSenderId: FIREBASE_MESSAGING_SENDER_ID,
appId: FIREBASE_APP_ID,
measurementId: FIREBASE_MEASUREMENT_ID,
};
const app = initializeApp(firebaseConfig);
export default app;
export const auth = getAuth(app);
export const firestore = getFirestore(app);
if (process.env.NODE_ENV === "development") {
connectAuthEmulator(auth, "http://localhost:9099");
connectFirestoreEmulator(firestore, "localhost", 8080);
}
Do let me know if you need to see more files or need to know more details.
发布评论
评论(10)
此处为 firebaser
我们的 JavaScript SDK 存在问题,Firebase 安装服务使用的 IDB 版本不支持浏览器环境之外的 ESM。该问题已在 版本 9.6.9 中得到修复JavaScript SDK,因此请务必更新。
firebaser here
There was a problem in our JavaScript SDKs, where Firebase Installation Services used a version of IDB that doesn't support ESM outside of browser environments. The issue has been fixed in version 9.6.9 of the JavaScript SDK, so be sure to update to that.
我遇到了同样的问题,看起来它在几天前发布的
"firebase": "^9.6.8",
上出现了问题。使用“firebase”:“9.6.7”,I'm getting the same issue, looks like, it's breaking on
"firebase": "^9.6.8",
which was released a few days ago. Use"firebase": "9.6.7",
我也遇到了同样的问题,我已经尝试了和你一样的方法,但没有成功。我对来自 firebase 测试实验室的日志进行了符号化,并得出了以下结论:
Stacktrace
一般来说,我不知道所有这些库如何协同工作,但是您是否将 typesense 与 firestore 一起使用?我想知道你的堆栈跟踪是否调用了相同的文件,但我在这里找不到任何确凿的证据。如果我发现什么,我会继续更新这个线程。 (我会发表评论,但我还没有代表)
更新:看起来我的构建只是以某种方式自行修复,甚至从本周末提交的构建也会不断崩溃。所以说实话,我不确定发生了什么,但可能会得到解决
I've been getting the same issue, I've tried all the same things as you to no avail. I symbolicated the logs from firebase test lab and came up with this:
Stacktrace
Generally I have no idea how all of these libraries work together, but are you using typesense with firestore? I wonder if your stack trace calls out the same files, but I can't find any smoking gun here. I'll keep updating this thread if I find something. (I would have commented but I don't have the rep yet)
Update: Looks like my build just fixed itself somehow, even submitting builds from this weekend that would constantly crash. So truly I'm not sure what happened but it may be resolved
我遇到了同样的问题,我的解决方案是将 Firebase 版本从 9.6.8 降级到 8.2.3。
这是一个可能有帮助的参考。
https://github.com/expo/expo-cli/issues/3066
I had the same issue, my solution was to downgrade the Firebase version from 9.6.8 to 8.2.3.
Here is a reference that could be helpful.
https://github.com/expo/expo-cli/issues/3066
我遇到了同样的问题,在尝试了多个不同的 firebase 版本之后,这是为我解决了错误的版本:
这是我发现此问题的地方: Cloud Firestore 入门
I had this same issue, and after trying multiple different firebase versions, this is the one that fixed the error for me:
Here's where I found this: Get Started with Cloud Firestore
该线程中提到的其他修复肯定都是有效的(我已经看到其他论坛帖子建议将 firebase 降级,但在我的情况下它不起作用。)
我认为这对我确认什么解决了我的情况下的问题可能会有所帮助。当我的一位团队成员使用
npm
而不是expo
(默认为yarn
)来安装依赖项时,出现了问题。这导致了yarn.lock
和package-lock.json
之间的同步问题。仅此一点不会造成太大问题,因为简单的yarn
或yarn install
就可以解决该问题。然而,这种依赖关系恰好需要预先存在的依赖关系,这些依赖关系的版本与我的博览会版本“预期”的版本不同。这个IDBIndex
错误是如何触发的对我来说仍然是个谜,但最终我所要做的就是删除所有锁定文件和node_modules
,执行expo update
并最后执行yarn
来重新安装所有现在兼容的软件包。如果任何人偶然发现这个答案都可以给出一个可能的解释来解释为什么这个问题是固定的,那将不胜感激。
The other fixes mentioned in this thread are definitely all valid (I have seen other forum posts suggesting the firebase downgrade but in my case it did not work.)
I thought it could be helpful for me to confirm what fixed the problem in my case. The problem arose from when one of my team members used
npm
instead ofexpo
(which defaults toyarn
) to install a dependency. This caused syncing issues between theyarn.lock
andpackage-lock.json
. This alone wouldn't have caused much of an issue because a simpleyarn
oryarn install <dependency>
would have solved the issue. However, this dependency happened to require pre-existing dependencies which were of a different version then the ones "expected" by my version of expo. How thisIDBIndex
error was triggered is still a mystery to me, but in the end all I had to do was remove all my lock files andnode_modules
, perform anexpo update
and finally do ayarn
to reinstall all now-compatible packages.If anyone stumbling across this answer can give a possible explanation as to why this fixed things, that would be much appreciated.
这是对我有用的(使用yarn):
yarnadd[电子邮件受保护]
yarn install
下载软件包,import firebase from "firebase/compat"
Here is what worked for me (using yarn):
yarn add [email protected]
yarn install
import firebase from "firebase/compat"
如果您使用 Firebase Analytics,请将其删除
Firebase 版本
"firebase": "9.6.7"
if you use firebase analytics, remove it
firebase version
"firebase": "9.6.7"
遇到了同样的问题,我刚刚降级了 firebase 版本,它就工作了。
您可以使用此代码进行降级:
Had the same issue, I just downgraded firebase version and it worked.
you can use this code for downgrading:
这适用于世博会:
https://github.com/firebase /firebase-js-sdk/issues/6253#issuecomment-1123923581
This worked for Expo:
https://github.com/firebase/firebase-js-sdk/issues/6253#issuecomment-1123923581