[英]./src/Firebase.js Module not found: Can't resolve 'firebase' in 'C:\Users\HP\Desktop\React\clones\disney-plus-clone\src'
I am working on a react project and I need firebase for authentication I have installed firebase using "npm i firebase" & firebase-tools using "npm i firebase-tools" also the path is correct.我正在处理一个反应项目,我需要 firebase 进行身份验证我已经使用“npm i firebase”和 firebase-tools 使用“npm i firebase-tools”安装了 firebase,路径也是正确的。 There is no problem in defining the path.
定义路径没有问题。 Everything from my side is correct then also it is showing the above error.
我这边的一切都是正确的,然后它也显示了上述错误。
--- Please help ----- - - 请帮忙 - - -
Why this is happening?为什么会这样?
If you give a look at firebase package version(inside package.json) then it's version 9. Now firebase has added a new compatibility option so can use the /compat folder in your imports.如果您查看 firebase 包版本(在 package.json 中),那么它是第 9 版。现在 firebase 添加了一个新的兼容性选项,因此可以在您的导入中使用 /compat 文件夹。
I have made some changes in Firebase.js file please replace your code with the given below and then start your dev server.
我对 Firebase.js 文件进行了一些更改,请将您的代码替换为下面给出的代码,然后启动您的开发服务器。
import firebase from "firebase/compat/app" import "firebase/compat/auth" import "firebase/compat/firestore" import "firebase/compat/storage" const firebaseConfig = { apiKey: "AIzaSyA9BnlX96fMf7XiUVCFRsoQzG8DGERJkeY", authDomain: "disneyplus-clone-a33d5.firebaseapp.com", projectId: "disneyplus-clone-a33d5", storageBucket: "disneyplus-clone-a33d5.appspot.com", messagingSenderId: "37918794208", appId: "1:37918794208:web:dbe9842dfe1dda522a4b85", measurementId: "G-DRVLJKWRWG", }; firebase.initializeApp(firebaseConfig); const db = firebase.firestore(); const auth = firebase.auth(); const provider = new firebase.auth.GoogleAuthProvider(); const storage =firebase.storage(); export { auth,provider,storage}; export default db;
@Gulshan Aggarwal This was a great solve! @Gulshan Aggarwal 这是一个很好的解决方案! Tks!
太棒了!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.