如何解决这个firebase导入错误?模块未找到:错误:未从包中导出包路径

s2j5cfk0  于 2023-01-14  发布在  其他
关注(0)|答案(1)|浏览(124)

我尝试从我的firebase.js文件导入auth,但当我输入import {auth} from "./firebase"时,我得到这个错误:

未找到模块:错误:无法解析“C:\用户\Zahraa\项目\netflix-build\src\屏幕”中的.“/firebase”

当我尝试import {auth} from "../firebase"时,我得到这个错误:

未找到模块:错误:包路径.未从包C:\Users\Zahraa\projects\netflix-build\node_modules\firebase中导出(请参阅C:\Users\Zahraa\projects\netflix-build\node_modules\firebase\package.json中的导出字段)您的意思是.“/firebase”吗?应在当前目录中解析的请求需要以.“/”开头。以名称开头的请求将被视为模块请求并在模块目录(node_modules,C:\Users\Zahraa\projects\netflix-build\node_modules)中解析。如果无法更改源代码,则还有一个名为“preferRelative”的解析选项,它也会尝试在当前目录中解析此类请求

我不确定是什么问题。这是我的firebase.js代码:

import firebase from "firebase";

const firebaseConfig = {
  apiKey: "AIzaSyDMFs_i60UUWNutBKJVzBkZ2U5W93JCnoM",
  authDomain: "netflix-clone-18cc6.firebaseapp.com",
  projectId: "netflix-clone-18cc6",
  storageBucket: "netflix-clone-18cc6.appspot.com",
  messagingSenderId: "1000960928424",
  appId: "1:1000960928424:web:e10790f27d2d1fa9b1f09d",
};

const firebaseApp = firebase.initializeApp(firebaseConfig);
const db =
  firebaseApp.firestore(); 
const auth = firebase.auth();

export { auth };
export default db;
wgx48brx

wgx48brx1#

import firebase from "firebase";
import { initializeApp } from "firebase/app";
import { getAuth } from "firebase/auth";

const firebaseConfig = {
  apiKey: "AIzaSyDMFs_i60UUWNutBKJVzBkZ2U5W93JCnoM",
  authDomain: "netflix-clone-18cc6.firebaseapp.com",
  projectId: "netflix-clone-18cc6",
  storageBucket: "netflix-clone-18cc6.appspot.com",
  messagingSenderId: "1000960928424",
  appId: "1:1000960928424:web:e10790f27d2d1fa9b1f09d",
};

const firebaseApp = firebase.initializeApp(firebaseConfig);
const db =
  firebaseApp.firestore(); 
  const app = initializeApp(firebaseConfig)
  export auth = getAuth(app)

export default db;

相关问题