import { firebase, initializeApp } from 'firebase/app'
import { GoogleAuthProvider } from 'firebase/auth'
import 'firebase/auth'
const firebaseConfig = {
apiKey: "xxx",
authDomain: "xxx",
databaseURL: "xxx",
projectId: "xxx",
storageBucket: "xxx",
messagingSenderId: "xxx",
appId: "xxx",
measurementId: "xxx"
};
firebase.initializeApp(firebaseConfig);
export const auth = firebase.auth();
const provider = new GoogleAuthProvider();
The code I have written is to implement google authentication in my web app. But it isn't working. It is throwing the error:
The requested module '/node_modules/.vite/firebase_app.js?v=e56c4a7d' does not provide an export named 'firebase'
SyntaxError: The requested module '/node_modules/.vite/firebase_app.js?v=e56c4a7d' does not provide an export named 'firebase'
You are using Firebase Modular SDK but also using the name-spaced syntax. Try refactoring the code as shown below:
import { firebase, initializeApp } from 'firebase/app'
import { getAuth, GoogleAuthProvider } from 'firebase/auth'
const firebaseConfig = {...};
const app = initializeApp(firebaseConfig);
const provider = new GoogleAuthProvider();
export const auth = getAuth(app);
The documentation has examples with both the syntaxes.