ERROR Class' FirebaseApp'错误地实现了界面' App'

时间:2018-02-03 11:51:09

标签: angular firebase npm

尝试提供我的angularCLI和Firebase导致此错误...我该怎么办?

  

node_modules / angularfire2 / app / firebase.app.module.d.ts(5,22)中的错误:   错误TS2420:Class' FirebaseApp'错误地实现接口   '应用&#39 ;.物业' firestore'类型' FirebaseApp'中缺少。   node_modules / angularfire2 / app / firebase.app.module.d.ts(12,28):错误   TS2694:命名空间' firebase'没有出口会员'承诺'。   node_modules / angularfire2 /数据库/ firebase_list_observable.d.ts(14,62):   错误TS2694:命名空间' firebase'没有出口会员'承诺'。   node_modules / angularfire2 /数据库/ firebase_list_observable.d.ts(15,48):   错误TS2694:命名空间' firebase'没有出口会员'承诺'。   node_modules / angularfire2 /数据库/ firebase_list_observable.d.ts(16,92):   错误TS2694:命名空间' firebase'没有出口会员'承诺'。   node_modules / angularfire2 / database / firebase_object_observable.d.ts(11,31):错误TS2694:命名空间' firebase'没有出口会员'承诺'。   node_modules / angularfire2 / database / firebase_object_observable.d.ts(12,37):错误TS2694:命名空间' firebase'没有出口会员'承诺'。   node_modules / angularfire2 / database / firebase_object_observable.d.ts(13,24):错误TS2694:命名空间' firebase'没有出口会员'承诺'。   node_modules / angularfire2 / interfaces.d.ts(12,32):错误TS2694:   命名空间&firebase'没有出口会员'承诺'。   node_modules / angularfire2 / interfaces.d.ts(13,35):错误TS2694:   命名空间&firebase'没有出口会员'承诺'。   node_modules / angularfire2 / interfaces.d.ts(14,35):错误TS2694:   命名空间&firebase'没有出口会员'承诺'。   node_modules / angularfire2 / interfaces.d.ts(15,44):错误TS2694:   命名空间&firebase'没有出口会员'承诺'。

     

webpack:无法编译。

的package.json

{
  "name": "oshop",
  "version": "0.0.0",
  "license": "MIT",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build --prod",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^5.2.0",
    "@angular/common": "^5.2.0",
    "@angular/compiler": "^5.2.0",
    "@angular/core": "^5.2.0",
    "@angular/forms": "^5.2.0",
    "@angular/http": "^5.2.0",
    "@angular/platform-browser": "^5.2.0",
    "@angular/platform-browser-dynamic": "^5.2.0",
    "@angular/router": "^5.2.0",
    "@ng-bootstrap/ng-bootstrap": "^1.0.0",
    "angularfire2": "^4.0.0-rc.1",
    "bootstrap": "^4.0.0",
    "core-js": "^2.4.1",
    "firebase": "^4.9.1",
    "rxjs": "^5.5.6",
    "zone.js": "^0.8.19"
  },
  "devDependencies": {
    "@angular/cli": "^1.6.7",
    "@angular/compiler-cli": "^5.2.0",
    "@angular/language-service": "^5.2.0",
    "@types/jasmine": "~2.8.3",
    "@types/jasminewd2": "~2.0.2",
    "@types/node": "~6.0.60",
    "codelyzer": "^4.0.1",
    "jasmine-core": "~2.8.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~2.0.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "^1.2.1",
    "karma-jasmine": "~1.1.0",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.1.2",
    "ts-node": "~4.1.0",
    "tslint": "~5.9.1",
    "typescript": "~2.5.3"
  },
  "description": "This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 1.6.7.",
  "main": "karma.conf.js",
  "author": "",
  "repository": {
    "type": "git",
    "url": "imnickvaughn"
  }
}

8 个答案:

答案 0 :(得分:5)

你应该先尝试: (如果你安装了角度cli和firebase)

  1. 在终端类型中:npm install -S angularfire2 @ latest
  2. 一旦你这样做,你的angularfire2将读取:         " angularfire2":" ^ 5.0.0-rc.6",

    ......就是这样

    如果这还不够,请查看这些来源并尝试...... https://github.com/angular/angularfire2/issues/1338 https://github.com/angular/angular-cli/issues/4391

    npm uninstall -g angular-cli
    npm cache clean
    npm install -g @angular/cli@latest
    
    rm -rf node_modules dist
    npm uninstall --save-dev angular-cli
    npm install --save-dev @angular/cli@latest
    npm install
    ng update [this wasn't working so I just changed it to ng init I believe]
    
    npm install -g firebase-tools
    npm install -S angularfire2@latest
    

    使用上述建议并重新安装所有依赖项也适用于此问题... npm WARN弃用了node-uuid@1.4.7:改为使用uuid模块 https://github.com/kelektiv/node-uuid/issues/155

    ...在我输入之前,firebase命令在我的oh-my-zsh中不会起作用:

    npm install -S -D -g firebase-tools
    

    进入vs代码终端。

    希望这可以节省一个小时或五个人......

答案 1 :(得分:2)

只需使用以下内容降级firebase版本:

首先,转到项目目录,然后转到此命令

 npm install --save firebase@3.9.*

它对我有用。

答案 2 :(得分:2)

对我来说修复是将FirebaseApp类更改为:

export declare class FirebaseApp implements FBApp {
name: string;
options: {};
auth: () => FirebaseAuth;
database: () => FirebaseDatabase;
messaging: () => FirebaseMessaging;
storage: () => FirebaseStorage;
delete: () => Promise<any>;
firestore: () => FirebaseFirestore;
automaticDataCollectionEnabled:boolean
}

答案 3 :(得分:2)

在json包中进行一些更改

“ angularfire2”:“ ^ 5.0.0-rc.6.0”, “ firebase”:“ ^ 4.12.1”

答案 4 :(得分:1)

我刚刚在课程currentDate = start.Date; currentDate = outTime.TimeOfDay; 中添加了automaticDataCollectionEnabled:boolean

这对我有用。

答案 5 :(得分:0)

我用了这个

export declare class FirebaseApp implements app.App {
    installations(): import("firebase").installations.Installations;
    performance(): import("firebase").performance.Performance;
    remoteConfig(): import("firebase").remoteConfig.RemoteConfig;
    analytics(): import("firebase").analytics.Analytics;
    name: string;
    options: {};
    auth: () => FirebaseAuth;
    database: (databaseURL?: string) => FirebaseDatabase;
    messaging: () => FirebaseMessaging;
    storage: (storageBucket?: string) => FirebaseStorage;
    delete: () => Promise<void>;
    firestore: () => FirebaseFirestore;
    functions: (region?: string) => FirebaseFunctions;
}

答案 6 :(得分:-1)

您遇到以下错误吗?

node_modules / angularfire2 / app / firebase.app.module.d.ts(5,22)中的错误

webpack:无法编译。

请不要执行任何操作,只需安装最新版本的 angularfire2 npm install -S angularfire2 @ latest

答案 7 :(得分:-1)

解决方案():

在您的Firebase项目中安装此命令

npm i --save firebase@5.10.1 angularfire2@5.1.2

它将起作用。