Keep getting "Firebase App named '[DEFAULT]' already exists." with copy & paste code from new console

29,526 views
Skip to first unread message

Frangeris Peguero

unread,
May 21, 2016, 7:42:48 PM5/21/16
to Firebase Google Group

Hey guys, I just copy & paste the code generate in the new firebase google console:

  var config = {
    apiKey: "...",
    authDomain: "...",
    databaseURL: "...",
    storageBucket: "",
  };
  firebase.initializeApp(config);

Using this version on npm:

 "firebase": "^3.0.2"

I just keep getting this error on console, and I don't know where is the issue....

Uncaught Error: Firebase App named '[DEFAULT]' already exists.

I'm not using multiples Apps explained https://firebase.google.com/docs/web/setup#advanced_usage, I just have 1 app inside firebase

Any help please, thank you...

Chris Raynor

unread,
May 21, 2016, 8:36:27 PM5/21/16
to Firebase Google Group

Hey Frangeris,

It looks like you're trying to initialize the SDK multiple times (maybe in a loop or in multiple files?) You should only initialize it once for the app (assuming you're only connecting to one project). It will then be initialized and available everywhere

Hope this helps

Chris


--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/f62fbc96-a85f-4147-8820-8462cfa24200%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Frangeris Peguero

unread,
May 22, 2016, 11:48:29 AM5/22/16
to Firebase Google Group
Yep, that was the issue...

Brandon Paquette

unread,
Jun 4, 2016, 1:51:00 AM6/4/16
to Firebase Google Group
what's the suggested guidance for browserify/webpack workflows? jam it into index.html, api key & all?

previously i just made a ref wherever i needed one. assuming i can still do that once i knock out the top-level firebase initialization?

Kato Richardson

unread,
Jun 4, 2016, 4:29:20 PM6/4/16
to Firebase Google Group

Brandon,

You can still create a ref any time you want. The equivalent to the old new Firebase(URL) is firebase.database().ref(URL); There’s no need to initialize everything each time you want one.

I’m not familiar enough with webpack/browserify to say if you need a shim or just to call the initializeApp() in some initialization workflow, but this is the part that should be called exactly once.

☼, Kato

Housekeeping:  Please create your own thread for tangentially related questions. This will make it easier for others to benefit from your questions by making them easier to search.



For more options, visit https://groups.google.com/d/optout.



--

Kato Richardson | Developer Programs Eng | kato...@google.com | 775-235-8398

Ron Royston

unread,
Jun 4, 2016, 4:33:39 PM6/4/16
to Firebase Google Group
            firebase.app().delete().then(function() {
                console.log("[DEFAULT] App is Gone Now");
            });

Mark Essel

unread,
Jun 8, 2016, 6:43:47 PM6/8/16
to Firebase Google Group
what about this use case: two different databaseAuthVariableOverride uids

  firebase.initializeApp({
    databaseURL
: config.Firebase.databaseURL,
    serviceAccount
: {
      projectId
: config.Firebase.projectId,
      clientEmail
: config.Firebase.clientEmail,
      privateKey
: config.Firebase.privateKey
   
},  
    databaseAuthVariableOverride
: {
      uid
: uidA
   
}
 
});



  firebase
.initializeApp({
    databaseURL
: config.Firebase.databaseURL,
    serviceAccount
: {
      projectId
: config.Firebase.projectId,
      clientEmail
: config.Firebase.clientEmail,
      privateKey
: config.Firebase.privateKey
   
},  
    databaseAuthVariableOverride
: {
      uid
: uidB
   
}
 
});


In one case I have a wrapper I use around firebase (in most of my code). In the other I have some old direct usage with a different uid

getting the same error Error: Firebase App named '[DEFAULT]' already exists.]

Jacob Wenger

unread,
Jun 8, 2016, 6:59:19 PM6/8/16
to fireba...@googlegroups.com
Hey Mark,

You can use the second argument to firebase.initializeApp() to give each app instance a unique name:


var configA = {
  databaseURL: config.Firebase.databaseURL,
  serviceAccount: {
    projectId: config.Firebase.projectId,
    clientEmail: config.Firebase.clientEmail,
    privateKey: config.Firebase.privateKey
  },   
  databaseAuthVariableOverride: {
    uid: uidA
  }
};

firebase.initializeApp(configA, 'appA');

var configB = {
  databaseURL: config.Firebase.databaseURL,
  serviceAccount: {
    projectId: config.Firebase.projectId,
    clientEmail: config.Firebase.clientEmail,
    privateKey: config.Firebase.privateKey
  },   
  databaseAuthVariableOverride: {
    uid: uidB
  }
};

firebase.initializeApp(configB, 'appB');

Cheers,
Jacob


--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To post to this group, send email to fireba...@googlegroups.com.

gmail

unread,
Jun 8, 2016, 8:53:10 PM6/8/16
to fireba...@googlegroups.com
got it thanks a bunch. It's working with the advanced usage: let db = firebase.intializeApp(), the unique name, and db.database etc now
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/7brZ2WqVcsc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-tal...@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

Mark Essel

unread,
Jun 9, 2016, 12:35:05 PM6/9/16
to Firebase Google Group
this helped clarify (even though it's server side)

I have different connections with different server users with customized permissions
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-talk+unsubscribe@googlegroups.com.

To post to this group, send email to fireba...@googlegroups.com.

--
You received this message because you are subscribed to a topic in the Google Groups "Firebase Google Group" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/firebase-talk/7brZ2WqVcsc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to firebase-talk+unsubscribe@googlegroups.com.

roger deutsch

unread,
Dec 19, 2018, 8:00:23 PM12/19/18
to Firebase Google Group
This solved my problem too.  I was getting the same error and found this link and discovered I was initializing the SDK multiple times in my javascript.  After I discovered what was wrong (thanks to this post) it was an easy fix.
Thanks
Reply all
Reply to author
Forward
0 new messages