问题描述
遇到一个很奇怪的问题.尝试导入Firebase时,出现以下错误:
Encountered a very weird issue. When trying to import firebase, I got the following error:
./node_modules/firebaseui/dist/esm.js
Attempted import error: 'app' is not exported from 'firebase/app' (imported as 'firebase').
我的项目的结构是:包含React Client文件夹的父文件夹.我在父文件夹中安装了Firebase,在父文件夹的firebaseConfig文件中初始化了一个Firebase应用程序,然后将其导入到react client文件夹中.
The structure of my project is: A parent folder containing a react client folder. I installed firebase in the parent folder, initialize a firebase app in the firebaseConfig file in the parent folder, and then import it into the react client folder.
我后来尝试在react client文件夹中安装firebase并在其中导入firebase.奇怪的是,我在客户端文件夹中安装了Firebase之后,执行"npm ls firebase"即使firebase确实位于节点模块中,并且客户端文件夹中的package.json也确实存在,客户端文件夹中的返回空.我想知道是什么原因引起的.
I later tried installing firebase in the react client folder and import firebase in it. Weirdly, after I installed firebase in the client folder, doing "npm ls firebase" in the client folder returns empty, even though firebase is indeed in the node modules and package.json in the client folder. I am wondering what caused the problem.
父文件夹中的firebaseConfig.js
import firebase from 'firebase/app';
import 'firebase/firestore';
import 'firebase/auth';
const firebaseConfig = {
......
};
firebase.initializeApp(firebaseConfig);
export default firebase;
推荐答案
不幸的是,您已经升级了"firebase".依赖于8.0.0,但"firebaseui"依赖关系尚不支持它.您将不得不暂时将Firebase降级到7.24.0版本,直到firebaseui支持破坏更改为8.0.0 .
Unfortunately, you've upgraded your "firebase" dependency to 8.0.0 but the "firebaseui" dependency doesn't support it yet. You will have to temporarily downgrade firebase to version 7.24.0 until firebaseui supports the breaking changes in 8.0.0.
这篇关于尝试导入错误:未从"firebase/app"中导出"app"(导入为"firebase")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!