[英]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.由于这一行代码,我在连接 Angular + Firebase 时遇到了问题。
AngularFireModule.initializeApp(environment.firebase)
The error is: Property 'firebase' does not exist on type '{ production: boolean;错误是:属性 'firebase' 不存在于类型 '{ production: boolean; }'.ts(2339) app.module.ts: }'.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!非常感谢!
I was able to resolve this issue by copy and pasting the content of environment.ts
to environment.prod.ts
, like this:我能够通过将environment.ts
的内容复制并粘贴到environment.prod.ts
来解决此问题,如下所示:
export const environment = {
production: true,
firebase: {
apiKey: "...",
authDomain: "project.firebaseapp.com",
databaseURL: "https://project.firebaseio.com",
projectId: "project",
storageBucket: "project.appspot.com",
messagingSenderId: "..."
}
};
使用您的 Firebase 配置更新您的/src/environments/environment.ts
文件: https : //github.com/angular/angularfire/blob/master/docs/install-and-setup.md#3-add-firebase-config-环境变量
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.