Search code examples
angularfirebaseangular8

Angular 8 + Firebase: Cannot initialize project due to AngularFireModule.initializeApp(environment.firebase)


I am having trouble in connecting Angular + Firebase due to this one line of code.

AngularFireModule.initializeApp(environment.firebase) 

The error is: Property 'firebase' does not exist on type '{ production: boolean; }'.ts(2339) app.module.ts:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { AppRoutingModule } from './app-routing.module';

import { AngularFireModule } from '@angular/fire';
import { AngularFireAuthModule } from '@angular/fire/auth';
import { AngularFirestoreModule, AngularFirestore } from 
'@angular/fire/firestore';

import { HomeComponent } from './home/home.component';
import { LoginComponent } from './login/login.component';
import { SignupComponent } from "./signup/signup.component"

import { AppComponent } from './app.component';
import { environment } from 'src/environments/environment';

@NgModule({
  declarations: [
    AppComponent,
    HomeComponent,
    LoginComponent,
    SignupComponent
  ],
  imports: [
    BrowserModule,
    FormsModule,
    AppRoutingModule,
    AngularFireModule.initializeApp(environment.firebase),
    AngularFireAuthModule,
    AngularFirestoreModule
  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

If you need any more segments of code from my project please let me know. Any help or feedback is greatly appreciated. Thanks a lot!


Solution

  • Update your /src/environments/environment.ts file with your Firebase configuration: https://github.com/angular/angularfire/blob/master/docs/install-and-setup.md#3-add-firebase-config-to-environments-variable