user8516249
user8516249

Reputation:

AngularFire - Firebase - call Firebase App.initializeApp() (app/no-app)

I've just started a new project using angular cli.

I have set up my firebase config in an environments fire.

I initialise the app in my app module but I get the following error:

Firebase: No Firebase App '[DEFAULT]' has been created - call Firebase App.initializeApp() (app/no-app).

App Module

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AppComponent } from './app.component';


// AngularFire and Firestore
import { AngularFireModule } from 'angularfire2';
import { AngularFirestoreModule } from 'angularfire2/firestore';

// Routing
import { AppRouting } from './routing/app-routing';

// Environment
import { environment } from '../environments/environment';

// Components
import { LoginModule } from './login/login.module';


 @NgModule({
  declarations: [
  AppComponent
 ],
 imports: [
  BrowserModule,
  AngularFireModule.initializeApp(environment.firebase), 
  AngularFirestoreModule,
  AppRouting,
  LoginModule
 ],
 providers: [],
 bootstrap: [AppComponent]
})
export class AppModule { }

My login component displays, but when I try to call 'createUserWithEmailAndPassword' I receive the error.

Login Component

import * as firebase from 'firebase';

...

createAccount(){
 firebase.auth().createUserWithEmailAndPassword(this.email, this.password).catch(function(error) {
  // Handle Errors here.
  var errorCode = error.code;
  var errorMessage = error.message;
  console.log(errorCode + ' / ' + errorMessage);
  // ...
 });
}

I've used the same setup in a previous project which is running on an older cli version. Any idea what this could be?

Upvotes: 1

Views: 1747

Answers (1)

Troels Lenda
Troels Lenda

Reputation: 524

In your login Component you’re not using angularfire2 which you initialized. You didn’t initialize the standard Firebase sdk

https://github.com/angular/angularfire2/blob/master/docs/auth/getting-started.md

Upvotes: 1

Related Questions