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",
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With