VM592 firebase-app.js:1 Uncaught FirebaseError: Firebase: Firebase App named '[DEFAULT]' already exists (app/duplicate-app). at initializeApp code example

Example: firebaseError: Firebase: Firebase App named '[DEFAULT'] already exists (app/duplicate-app).

// Config file
import * as firebase from "firebase";

const config = {...};

export default !firebase.apps.length ? firebase.initializeApp(config) : firebase.app();

// Other file
import firebase from '../firebase';
...
console.log(firebase.name);
console.log(firebase.database());

Tags:

Misc Example