title: Firebase Initialization Error: App Default not created and App Default already exists
body: <p>I have already asked this question before and the solution was to restart my server. I'm using the same code again but this time server restart doesn't help.</p>
  <pre><code>import firebase from &quot;firebase&quot;;
  
  const firebaseConfig = {
      apiKey: &quot;...&quot;,
      authDomain: &quot;...&quot;,
      projectId: &quot;...&quot;,
      storageBucket: &quot;...&quot;,
      messagingSenderId: &quot;...&quot;,
      appId: &quot;...&quot;
  };
  
  if(!firebase.app.length){
      firebase.initializeApp(firebaseConfig);
  }
  
  const db = firebase.firestore();
  const auth = firebase.auth();
  const provider = new firebase.auth.GoogleAuthProvider();
  
  
  export {db, auth, provider};
  </code></pre>
  <p>Entire error from console: <a href="https://i.imgur.com/bLK7PpX.png" rel="nofollow noreferrer">https://i.imgur.com/bLK7PpX.png</a> .</p>
  <p>If I initialize it out of if statement it gives me and error that default app already exists;  tried placing both in if else:</p>
  <pre><code>if(!firebase.app.length){
      firebase.initializeApp(firebaseConfig);
  }else{
      firebase.app();
  }
  </code></pre>
  <p>but then it goes back to &quot;No Firebase App Default has been created&quot;.</p>