OiO.lk Community platform!

Oio.lk is an excellent forum for developers, providing a wide range of resources, discussions, and support for those in the developer community. Join oio.lk today to connect with like-minded professionals, share insights, and stay updated on the latest trends and technologies in the development field.
  You need to log in or register to access the solved answers to this problem.
  • You have reached the maximum number of guest views allowed
  • Please register below to remove this limitation

The requested module '/node_modules/.vite/deps/firebase_app.js?v=bdc3ec1e' does not provide an export named 'getApps'

  • Thread starter Thread starter DevMatt
  • Start date Start date
D

DevMatt

Guest
Haven't had an issue until all of a sudden today. I have not changed any firebase.js code or any firebase rules anytime recently that could cause such an error. I'm using Vue 3 with Vite. I'm currently on Firebase version 10.0.0 which is latest.

Error:

Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/firebase_app.js?v=bdc3ec1e' does not provide an export named 'getApps' (at firebase.js:1:471)

firebase.js

Code:
import {
  getApps,
  initializeApp
} from "firebase/app";

import {
  getAuth,
  onAuthStateChanged,
  sendEmailVerification
} from "firebase/auth";

const firebaseConfig = {
  apiKey: import.meta.env.VITE_APP_API_KEY,
  authDomain: import.meta.env.VITE_APP_AUTH_DOMAIN,
  projectId: import.meta.env.VITE_APP_PROJECT_ID,
  storageBucket: import.meta.env.VITE_APP_STORAGE_BUCKET,
  messagingSenderId: import.meta.env.VITE_APP_MESSAGING_SENDER_ID,
  appId: import.meta.env.VITE_APP_APP_ID,
  measurementId: import.meta.env.VITE_APP_MEASUREMENT_ID
};

const apps = getApps()
const firebaseApp = !apps.length ? initializeApp(firebaseConfig) : apps[0]
const firebaseAuth = getAuth(firebaseApp)

const getCurrentUser = () => new Promise((resolve, reject) => {
  const unsub = onAuthStateChanged(firebaseAuth, user => {
    unsub()
    resolve(user)
  }, reject)
})

export const createUserWithEmailAndPassword = (email, password) => {
  return firebaseAuth.createUserWithEmailAndPassword(email, password)
}

export const signInWithEmailAndPassword = (email, password) => {
  return firebaseAuth.signInWithEmailAndPassword(email, password)
}

// send Email Verification to user after sign up
export const sendEmailVerificationToUser = () => {
  return sendEmailVerification(firebaseAuth.currentUser)
}

// reauthenticateUser, updatePassword
export const reauthenticateUser = (password) => {
  const user = firebaseAuth.currentUser
  const cred = firebaseAuth.EmailAuthProvider.credential(user.email, password)
  return user.reauthenticateWithCredential(cred)
}

export const updatePassword = (password) => {
  return firebaseAuth.currentUser.updatePassword(password)
}

export { firebaseApp, firebaseAuth, getCurrentUser }

<p>Haven't had an issue until all of a sudden today. I have not changed any firebase.js code or any firebase rules anytime recently that could cause such an error. I'm using Vue 3 with Vite. I'm currently on Firebase version 10.0.0 which is latest.</p>
<p><strong>Error:</strong></p>
<p><em>Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/firebase_app.js?v=bdc3ec1e' does not provide an export named 'getApps' (at firebase.js:1:471)</em></p>
<p><strong>firebase.js</strong></p>
<pre class="lang-js prettyprint-override"><code>import {
getApps,
initializeApp
} from "firebase/app";

import {
getAuth,
onAuthStateChanged,
sendEmailVerification
} from "firebase/auth";

const firebaseConfig = {
apiKey: import.meta.env.VITE_APP_API_KEY,
authDomain: import.meta.env.VITE_APP_AUTH_DOMAIN,
projectId: import.meta.env.VITE_APP_PROJECT_ID,
storageBucket: import.meta.env.VITE_APP_STORAGE_BUCKET,
messagingSenderId: import.meta.env.VITE_APP_MESSAGING_SENDER_ID,
appId: import.meta.env.VITE_APP_APP_ID,
measurementId: import.meta.env.VITE_APP_MEASUREMENT_ID
};

const apps = getApps()
const firebaseApp = !apps.length ? initializeApp(firebaseConfig) : apps[0]
const firebaseAuth = getAuth(firebaseApp)

const getCurrentUser = () => new Promise((resolve, reject) => {
const unsub = onAuthStateChanged(firebaseAuth, user => {
unsub()
resolve(user)
}, reject)
})

export const createUserWithEmailAndPassword = (email, password) => {
return firebaseAuth.createUserWithEmailAndPassword(email, password)
}

export const signInWithEmailAndPassword = (email, password) => {
return firebaseAuth.signInWithEmailAndPassword(email, password)
}

// send Email Verification to user after sign up
export const sendEmailVerificationToUser = () => {
return sendEmailVerification(firebaseAuth.currentUser)
}

// reauthenticateUser, updatePassword
export const reauthenticateUser = (password) => {
const user = firebaseAuth.currentUser
const cred = firebaseAuth.EmailAuthProvider.credential(user.email, password)
return user.reauthenticateWithCredential(cred)
}

export const updatePassword = (password) => {
return firebaseAuth.currentUser.updatePassword(password)
}

export { firebaseApp, firebaseAuth, getCurrentUser }
</code></pre>
 

Latest posts

H
Replies
0
Views
1
haifisch123
H
A
Replies
0
Views
1
Adrian-Mihai Enache
A
H
Replies
0
Views
1
Hür Doğan ÜNLÜ
H
Top