Error: no Firebase application '[DEFAULT]' - call Firebase App.initializeApp ()

I have a firebase database associated with two applications, one of which is an iOS application, and the other is a web application encoded in node.js, which is the basic algorithm that sets the data to the database. When I run the algorithm that I come across -

Error: No Firebase application '[DEFAULT]' - call Firebase App.initializeApp (). on error (native) in R (/ Users / dd / Desktop / Code / NODE / node_modules / firebase / app-node.js: 22: 335) on (/ Users / dd / Desktop / Code / NODE / node_modules / firebase / app-node.js: 20: 68) in Object.c [as a database] (/Users/dd/Desktop/Code/NODE/node_modules/firebase/app-node.js:21-00-0047) in the object. (/Users/dd/Desktop/Code/NODE/Bot.js:24:25) on Module._compile (module.js: 570: 32) in Object.Module._extensions..js (module.js: 579: 10 ) on Module.load (module.js: 487: 32) in tryModuleLoad (module.js: 446: 12) in Function.Module._load (module.js: 438: 3) on Module.runMain (module.js: 604 : 10) on startup (bootstrap_node.js: 394: 7) on startup (bootstrap_node.js: 149: 9) on bootstrap_node.js: 509: 3 dd-mac: NODE dd $

Can anyone help?

+23
javascript ios firebase firebase-database firebase-realtime-database
source share
7 answers

You are probably calling firebase before the application is initialized. All firebase. calls firebase. should appear after .initializeApp();

 firebase.initializeApp(config); var db = firebase.firestore(); 
+14
source share

Full tutorial source link

Use initializeApp before @NgModule

  import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { RouteReuseStrategy } from '@angular/router'; import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; import { SplashScreen } from '@ionic-native/splash-screen/ngx'; import { StatusBar } from '@ionic-native/status-bar/ngx'; import { AppComponent } from './app.component'; import { AppRoutingModule } from './app-routing.module'; import { environment } from 'src/environments/environment'; import { AuthenticateService } from './services/authentication.service'; import { AngularFireAuthModule } from '@angular/fire/auth'; import * as firebase from 'firebase'; firebase.initializeApp(environment.firebase); @NgModule({ declarations: [AppComponent], entryComponents: [], imports: [ BrowserModule, IonicModule.forRoot(), AppRoutingModule, AngularFireAuthModule ], providers: [ StatusBar, SplashScreen, AuthenticateService, { provide: RouteReuseStrategy, useClass: IonicRouteStrategy } ], bootstrap: [AppComponent] }) export class AppModule {} 
+7
source share

I had a similar problem after the Firebase internet guide found here .

The title of the section “Initializing Multiple Applications” is misleading since the first example under this heading actually demonstrates how to initialize a single application by default. Here is an example:

 // Initialize the default app var defaultApp = admin.initializeApp(defaultAppConfig); console.log(defaultApp.name); // "[DEFAULT]" // Retrieve services via the defaultApp variable... var defaultAuth = defaultApp.auth(); var defaultDatabase = defaultApp.database(); // ... or use the equivalent shorthand notation defaultAuth = admin.auth(); defaultDatabase = admin.database(); 

If you upgrade from the previous 2.x SDK, you will have to update the database access method as shown above, or you will receive the No Firebase App '[DEFAULT]' error message No Firebase App '[DEFAULT]' .

Google has the best documentation in the following:

  1. INITIALIZATION: https://firebase.google.com/docs/database/admin/start

  2. SAVE: https://firebase.google.com/docs/database/admin/save-data

  3. GET: https://firebase.google.com/docs/database/admin/retrieve-data

+5
source share

This may not be the best answer, but I had to initialize the application using admin and firebase, as shown below. I use admin for my purposes and for firebase.

 const firebase = require("firebase"); const admin = require("firebase-admin"); admin.initializeApp(functions.config().firebase); firebase.initializeApp(functions.config().firebase); // Get the Auth service for the default app var authService = firebase.auth(); function createUserWithEmailAndPassword(request, response) { const email = request.query.email; const password = request.query.password; if (!email) { response.send("query.email is required."); return; } if (!password) { response.send("query.password is required."); return; } return authService.createUserWithEmailAndPassword(email, password) .then(success => { let responseJson = JSON.stringify(success); console.log("createUserWithEmailAndPassword.responseJson", responseJson); response.send(responseJson); }) .catch(error => { let errorJson = JSON.stringify(error); console.log("createUserWithEmailAndPassword.errorJson", errorJson); response.send(errorJson); }); } 
+4
source share

My problem was that I added a second parameter:

 AngularFireModule.initializeApp(firebaseConfig, 'reservas') 

if I remove the second parameter, it works fine:

 AngularFireModule.initializeApp(firebaseConfig) 
+2
source share

YOU CALL THIS IN JADE: firebase.initializeApp (config); STARTING FUNC

 script. function signInWithGoogle() { firebase.initializeApp(config); var googleAuthProvider = new firebase.auth.GoogleAuthProvider firebase.auth().signInWithPopup(googleAuthProvider) .then(function (data){ console.log(data) }) .catch(function(error){ console.log(error) }) } 
0
source share

I had the same problem and I just fixed the removal of the second instance call parameter. For example:

 firebase.initializeApp(environment.firebase); 

Instead

 firebase.initializeApp(environment.firebase, 'orders') 
0
source share

All Articles