angular – 属性’firebase’不存在于类型{production:boolean; }

前端之家收集整理的这篇文章主要介绍了angular – 属性’firebase’不存在于类型{production:boolean; }前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
所以我试图在Firebase和Heroku上构建和部署我的Angular 4应用程序,但是我遇到了如下错误

ERROR in /Users/…/… (57,49): Property ‘firebase’ does not exist
on type ‘{ production: boolean; }’.

它发生在我运行build –prod时,我的部署服务器工作正常.这是我的app.module.ts文件,供参考:

  1. import { BrowserModule } from '@angular/platform-browser';
  2. import { NgModule } from '@angular/core';
  3. import { FormsModule } from '@angular/forms';
  4. import { AngularFireModule } from 'angularfire2';
  5. import { AngularFireDatabaseModule } from 'angularfire2/database';
  6. import { Ng2ScrollimateModule } from 'ng2-scrollimate';
  7. import { Ng2PageScrollModule } from 'ng2-page-scroll';
  8.  
  9. import { HttpModule } from '@angular/http';
  10. import {
  11. trigger,state,style,animate,transition,keyframes
  12. } from '@angular/animations';
  13. import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
  14. import { environment } from '../environments/environment';
  15.  
  16. import { AppComponent } from './app.component';
  17.  
  18. import { logoComponent } from './logo/logo.component';
  19. import { InfoComponent } from './info/info.component';
  20. import { AboutComponent } from './about/about.component';
  21. import { DividerComponent } from './divider/divider.component';
  22. import { ProficienciesComponent } from './proficiencies/proficiencies.component';
  23. import { ProficiencyComponent } from './proficiency/proficiency.component';
  24. import { PortfolioComponent } from './portfolio/portfolio.component';
  25. import { ProjectComponent } from './project/project.component';
  26. import { ResumeComponent } from './resume/resume.component';
  27. import { FooterComponent } from './footer/footer.component';
  28. import { ContactComponent } from './contact/contact.component';
  29. import { LoadingComponent } from './loading/loading.component';
  30.  
  31. @NgModule({
  32. declarations: [
  33. AppComponent,logoComponent,InfoComponent,AboutComponent,DividerComponent,ProficienciesComponent,ProficiencyComponent,PortfolioComponent,ProjectComponent,ResumeComponent,FooterComponent,ContactComponent,LoadingComponent
  34. ],imports: [
  35. BrowserModule,FormsModule,HttpModule,BrowserAnimationsModule,AngularFireModule.initializeApp(environment.firebase),AngularFireDatabaseModule,Ng2ScrollimateModule,Ng2PageScrollModule.forRoot()
  36. ],providers: [],bootstrap: [AppComponent]
  37. })
  38. export class AppModule { }

environment.prod.ts

  1. export const environment = {
  2. production: true
  3. };

environment.ts

  1. export const environment = {
  2. production: true,firebase: {
  3. apiKey: "...",authDomain: "project.firebaseapp.com",databaseURL: "https://project.firebaseio.com",projectId: "project",storageBucket: "project.appspot.com",messagingSenderId: "..."
  4. }
  5. };

在使用StackOverflow和GitHub寻找可能的解决方案之后,似乎没有开发人员遇到过这个确切的错误并发布了他们的发现,所以我想知道是否有人知道如何解决这个问题.非常感谢提前!

运行build时–prod angular-cli将使用environment.prod.ts文件,而environment.prod.ts文件环境变量没有firebase字段,因此您将获得异常.

将字段添加
environment.prod.ts

  1. export const environment = {
  2. production: true,firebase: {
  3. apiKey: "...",messagingSenderId: "..."
  4. }
  5. };

猜你在找的Angularjs相关文章