gpt4 book ai didi

javascript - 当我使用 import * as firebase from 'firebase' 导入 firebase 时;?

转载 作者:行者123 更新时间:2023-12-05 00:30:14 25 4
gpt4 key购买 nike

告诉我这个错误?

无法从“App.js”解析“firebase”
构建 JavaScript 包失败。

我曾尝试寻找答案,但这些是针对以前的 firebase 版本的,我也尝试添加此导入,但没有解决我的问题。

从“@firebase/app”导入 firebase

},
"dependencies": {
"expo": "^33.0.0",
"firebase": "^6.3.0",
"native-base": "^2.12.1",
"react": "16.8.3",
"react-dom": "^16.8.6",
"react-native": "https://github.com/expo/react-native/archive/sdk-
33.0.0.tar.gz",
"react-native-gesture-handler": "^1.3.0",
"react-native-web": "^0.11.4",
"react-navigation": "^3.11.1"
},

有人可以帮忙吗

最佳答案

您应该以这种方式更新导入和代码以使其正常工作。

import firebase from 'firebase/compat/app';
import 'firebase/compat/auth';
import 'firebase/compat/firestore';

const firebaseConfig = { // Have the firebase config here
apiKey: "",
authDomain: "",
projectId: "",
storageBucket: "",
messagingSenderId: "",
appId: "",
measurementId: ""
};

// Use this to initialize the firebase App
const firebaseApp = firebase.initializeApp(firebaseConfig);

// Use these for db & auth
const db = firebaseApp.firestore();
const auth = firebase.auth();

export { auth, db };

关于javascript - 当我使用 import * as firebase from 'firebase' 导入 firebase 时;?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57070147/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com