加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

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

发布时间:2020-12-17 08:02:51 所属栏目:安全 来源:网络整理
导读:所以我试图在Firebase和Heroku上构建和部署我的Angular 4应用程序,但是我遇到了如下错误: ERROR in /Users/…/… (57,49): Property ‘firebase’ does not exist on type ‘{ production: boolean; }’. 它发生在我运行build –prod时,我的部署服务器工作
所以我试图在Firebase和Heroku上构建和部署我的Angular 4应用程序,但是我遇到了如下错误:

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

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

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { AngularFireModule } from 'angularfire2';
import { AngularFireDatabaseModule } from 'angularfire2/database';
import { Ng2ScrollimateModule } from 'ng2-scrollimate';
import { Ng2PageScrollModule } from 'ng2-page-scroll';

import { HttpModule } from '@angular/http';
import {
  trigger,state,style,animate,transition,keyframes
} from '@angular/animations';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { environment } from '../environments/environment';

import { AppComponent } from './app.component';

import { LogoComponent } from './logo/logo.component';
import { InfoComponent } from './info/info.component';
import { AboutComponent } from './about/about.component';
import { DividerComponent } from './divider/divider.component';
import { ProficienciesComponent } from './proficiencies/proficiencies.component';
import { ProficiencyComponent } from './proficiency/proficiency.component';
import { PortfolioComponent } from './portfolio/portfolio.component';
import { ProjectComponent } from './project/project.component';
import { ResumeComponent } from './resume/resume.component';
import { FooterComponent } from './footer/footer.component';
import { ContactComponent } from './contact/contact.component';
import { LoadingComponent } from './loading/loading.component';

@NgModule({
  declarations: [
    AppComponent,LogoComponent,InfoComponent,AboutComponent,DividerComponent,ProficienciesComponent,ProficiencyComponent,PortfolioComponent,ProjectComponent,ResumeComponent,FooterComponent,ContactComponent,LoadingComponent
  ],imports: [
    BrowserModule,FormsModule,HttpModule,BrowserAnimationsModule,AngularFireModule.initializeApp(environment.firebase),AngularFireDatabaseModule,Ng2ScrollimateModule,Ng2PageScrollModule.forRoot()
  ],providers: [],bootstrap: [AppComponent]
})
export class AppModule { }

environment.prod.ts

export const environment = {
  production: true
};

environment.ts

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

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

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

将字段添加到
environment.prod.ts

export const environment = {
  production: true,firebase: {
    apiKey: "...",messagingSenderId: "..."
  }
};

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读