[英]firebase.firestore is not a function with Node.js
I am currently facing a problem with Firebase on my React Native app.我目前在我的 React Native 应用程序上遇到 Firebase 的问题。 Whenever I try to launch my app, I have the error:"TypeError: firebase.firestore is not a function."
每当我尝试启动我的应用程序时,都会出现错误:“TypeError: firebase.firestore is not a function。”
I tried many solutions, like importing我尝试了很多解决方案,例如导入
var firebase = require("firebase/app")
require("firebase/firestore")
But it is not working.但它不起作用。 My firebase has the latest version.
我的 firebase 有最新版本。
Here is my code这是我的代码
import * as firebase from "firebase/app";
import "firebase/firestore";
import "firebase/storage";
// Initialize Firebase
firebaseConfig = {
...
};
var firebaseConfig = firebase.initializeApp(firebaseConfig);
export const st = firebase.storage();
const fr = firebase.firestore();
Do you guys have any solutions?各位有什么解决办法吗? Thanks in advance
提前致谢
try this, do not import all:试试这个,不要全部导入:
import firebase from 'firebase/app'
require('firebase/firestore')
require('firebase/storage')
// Initialize Firebase
firebaseConfig = {
...
};
var firebaseConfig = firebase.initializeApp(firebaseConfig);
export const st = firebase.storage();
const fr = firebase.firestore();
After a complete check of all my code, I realised that I also called firebase.firestore in another file.在完整检查了我的所有代码后,我意识到我还在另一个文件中调用了 firebase.firestore。 I didn't know that the error was there because the error was not specifying where the error was.
我不知道错误在那里,因为错误没有指定错误在哪里。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.