简体   繁体   English

./src/Firebase.js 模块未找到:无法解析“C:\\Users\\HP\\Desktop\\React\\clone\\disney-plus-clone\\src”中的“firebase”

[英]./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.

相关问题 未找到模块:无法解析“C:\Users\Mohammad\Desktop\Chat-System\src\components”中的“..src/firebase.js” - Module not found: Can't resolve '..src/firebase.js' in 'C:\Users\Mohammad\Desktop\Chat-System\src\components' ./src/firebase.js 未找到模块:无法解析“D:\\Coding\\fb-clone\\src”中的“firebase” - ./src/firebase.js Module not found: Can't resolve 'firebase' in 'D:\Coding\fb-clone\src' ./src/index.js 找不到模块:无法解析“c:\users\.....”中的“react-dom/client” - ./src/index.js Module not found: Can't resolve 'react-dom/client' in "c:\users\....." "无法从“firebase.js”解析模块“firebase”:在项目中找不到 Firebase" - Cannot resolve module "firebase" from 'firebase.js' : Firebase could not be found within the project 找不到模块:无法在 React JS 中解析“firebase” - Module not found: Can't resolve 'firebase' in react js 未找到模块:无法解析“C:\Users\krish\Downloads\krishtest\reactapp\src”中的“组件/露营地” - Module not found: Can't resolve 'components/Campgrounds' in 'C:\Users\krish\Downloads\krishtest\reactapp\src' 找不到模块:无法解析“C:\Users\Zaid Mohammed\Umm.netic\umm.netic\src”中的“Umma.PNG” - Module not found: Can't resolve 'Umma.PNG' in 'C:\Users\Zaid Mohammed\Ummanetic\ummanetic\src' 找不到模块:无法解析“C:\react-test\src\components\content”中的“node_modules/react” - Module not found: Can't resolve 'node_modules/react' in 'C:\react-test\src\components\content' React Native:找不到模块:无法解析'./src/BlurView' - React Native: Module not found: Can't resolve './src/BlurView' 反应:找不到模块:无法解析“/usr/src/app/src”中的“react-router-dom” - React: Module not found: Can't resolve 'react-router-dom' in '/usr/src/app/src'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM