在部署代码时出现此错误。
src / app / app.module.ts(26,49)中的错误: 错误TS2339:属性'firebaseConfig'在类型'{上不存在 生产:布尔; }”。
App.module.ts
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { AngularFireModule } from 'angularfire2';
import { AngularFireDatabaseModule } from 'angularfire2/database';
import { FormsModule } from '@angular/forms';
import { AppComponent } from './app.component';
import { environment } from '../environments/environment';
import { ContactsComponent } from './contacts/contacts.component';
import { ContactComponent } from './contacts/contact/contact.component';
import { ContactListComponent } from './contacts/contact-list/contact-list.component';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { ToastrModule } from 'ngx-toastr';
@NgModule({
declarations: [
AppComponent,
ContactsComponent,
ContactComponent,
ContactListComponent
],
imports: [
BrowserModule,
AngularFireModule.initializeApp(environment.firebaseConfig),
AngularFireDatabaseModule,
FormsModule,
BrowserModule,
BrowserAnimationsModule,
ToastrModule.forRoot()
],
providers: [],
bootstrap: [AppComponent]
})
export class AppModule { }
任何人都可以帮助我。
这是我的环境配置
export const environment = {
production: false,
firebaseConfig: {
apiKey: "AIzaSyAyVk7gK3ZL8RJ1vDuMm5pwJKDTJKQZbZ0",
authDomain: "contactlist-163b0.firebaseapp.com",
databaseURL: "https://contactlist-163b0.firebaseio.com",
projectId: "contactlist-163b0",
storageBucket: "",
messagingSenderId: "593204922920"
}
};
答案 0 :(得分:2)
您需要添加' firebaseConfig'您环境中的配置.prod.ts'文件也是。
答案 1 :(得分:0)
您需要在environment.prod.ts中添加相同的配置firebase配置,如下所示:
firebaseConfig: {
apiKey: "AIzaSyAyVk7gK3ZL8RJ1vDuMm5pwJKDTJKQZbZ0",
authDomain: "contactlist-163b0.firebaseapp.com",
databaseURL: "https://contactlist-163b0.firebaseio.com",
projectId: "contactlist-163b0",
storageBucket: "",
messagingSenderId: "593204922920"
}
答案 2 :(得分:0)
在您的src / environments / enviorment.ts文件中
export const environment = {
production: false,
firebaseConfig: {
apiKey: 'apiKey',
authDomain: 'authDomain',
databaseURL: 'databaseURL',
projectId: 'projectId',
storageBucket: 'storageBucket',
messagingSenderId: 'messagingSenderId',
appId: 'appId',
measurementId: 'measurementId'
}
};
在您的app.module.ts文件中
import { AngularFireModule, FirebaseOptionsToken } from '@angular/fire';
import { environment } from 'src/environments/environment';
imports: [
AngularFireModule
],
providers: [{ provide: FirebaseOptionsToken, useValue: environment.firebaseConfig }]