class AngularfireModule is not an angular module

Viewed 4040

I tried to use firebase in my Angular app:

import {AngularFireModule} from 'angularfire2';
import {AngularFireDatabaseModule} from 'angularfire2/database';
import {environment} from '../environments/environment';
...

@NgModule({
    ...
    imports: [
        BrowserModule,
        ...
        AngularFireDatabaseModule,
        AngularFireModule.initializeApp(environment.firebaseConfig, 'my-app')
    ],
    ...
})

However, I got an error:

class AngularfireModule is not an Angular Module

and

class AngularFireDatabaseModule is not an Angular Module

I don't know if this is the correct way to use Firebase with Angular 8, or if there is another way.

2 Answers

You need to download @angular/fire not angularfire2. angularfire2 is an old version of @angular/fire.

Angular 6+ or 7/8+ command ng add @angular/fire.

As mentioned by Mises, angularfire2 is an older version, current angular firebase commands are: To install firebase: npm install firebase or npm install firebase @angular/fire Now in app.module.ts

import {AngularFireModule} from '@angular/fire'
import {AngularFireDatabaseModule} from '@angular/fire/database'

Also, add these two modules in imports array below in app.module.ts

Related