当前位置: 首页 > 知识库问答 >
问题:

类型{production:Boolean;}上不存在属性“FireBase”

闻人昕
2023-03-14

因此,我试图在Firebase和Heroku上构建和部署Angular 4应用程序,但我遇到了如下错误:

/Users/.../...中出错(57,49):属性“FireBase”在类型“{Production:Boolean;}”上不存在。

当我运行ng 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 {}
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以寻找可能的解决方案之后,似乎没有开发人员遇到过这个确切的错误并公布了他们的发现,所以我想知道是否有人知道如何着手解决这个问题。提前谢谢你!

共有1个答案

屈健柏
2023-03-14

运行NG Build--prodAngular-CLI将使用Environment.prod.ts文件,而Environment.prod.tsfilesEnvironment变量没有Firebase字段,因此会出现异常。

将该字段添加到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: '...',
  },
};
 类似资料:
  • 我使用的是完全修补过的Visual Studio 2013。我正在尝试使用JQuery、JQueryUI和JSRender。我也在尝试使用打字。在ts文件中,我得到如下错误: 类型“{}”上不存在属性“fade div”。

  • 我试图在登录过程后获得连接的用户模型, 首先,在CanActivate guard检查了带有用户JSON对象的本地存储并发现该对象为空之后,用户将重定向到“/login”URL 然后用户登录并重定向回根URL“/”,在连接过程中我使用AuthService,它将从服务器返回的用户对象保存在用户模型中 这是我的守卫:

  • 升级到Angular 6.0和Rxjs到6.0后,我收到以下编译错误:

  • 获取错误:(类型窗口中不存在属性“MktoForms2”

  • 我试图在TypeScript中使用“时刻-持续时间格式”,但即使它有效,webpack仍不断抱怨它无法在线找到“格式”方法: 这里是package.json tsconfig.json: 在(angular2)组件中: 我也试过了 但这并不能改变什么: [at-loader]./src/app/组件/建筑/商店/shop.component.ts:190中的错误:81 TS2339:属性“格式”在

  • 嗨,我正在使用Angular 2 final和router 3.0。我想过滤从 我想做的是: 可以是instanceOf,或,但我只想要。但是我得到一个错误