Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Function calls are not supported in decorators but 'AngularFireModule' was called

I am using Firebase as a database for my Angular 5 application. I am able to build, run, and deploy the project using ng build. However, when I build using the --prod flag, I get the following error.

Using:

ng build --prod

I get the following error:

ERROR in Error during template compile of 'FirebaseModule' Function calls are not supported in decorators but 'AngularFireModule' was called.

I don't understand how to configure the AngularFire module so that it works.

Firebase.Module.ts:

import { NgModule } from "@angular/core";
import { CommonModule } from "@angular/common";
import { environment } from "../environments/environment";       // Firebase config stored in environment file

import { AngularFireAuthModule } from "angularfire2/auth";
import { AngularFireModule } from "angularfire2/angularfire2";
import { AngularFirestoreModule } from "angularfire2/firestore";

@NgModule({
  imports: [
    AngularFireModule.initializeApp(environment.firebase),  // Error is here
    AngularFireAuthModule,
    AngularFirestoreModule
  ],
  exports: [AngularFireModule, AngularFireAuthModule, AngularFirestoreModule],
  providers: [],
  declarations: []
})
export class FirebaseModule {}

environment.ts (and environment.prod.ts)

export const environment = {
     production: false,
     firebase: {
       apiKey: "...",
       authDomain: "...",
       databaseURL: "...",
       projectId: "...",
       storageBucket: "",
       messagingSenderId: "..."
     }
};

Package Versions

"angularfire2": "^5.0.0-rc.4",
"firebase": "^4.8.1",

AskFirebase

like image 576
Darren Neimke Avatar asked Jan 21 '18 22:01

Darren Neimke


1 Answers

I also encountered this error. The angularfire2 team already fixed this in rc9 and it works perfectly fine right now. Just update the library using this command

npm install @[email protected]

Hope this helps.

like image 65
brijmcq Avatar answered Oct 11 '22 11:10

brijmcq