角度错误:找不到模块“ firebase / app”

时间:2019-03-09 05:34:53

标签: angular firebase npm

我正在尝试遵循Google的代码实验室: https://codelabs.developers.google.com/codelabs/firebase-cloud-functions-angular/index.html?index=..%2F..index#5

当我尝试构建项目:ng build --prod时,出现以下错误:

  

node_modules/@angular/fire/database/interfaces.d.ts(2,26)中的错误:   错误TS2307:找不到模块“ firebase / app”。

package.json

 "dependencies": {
    "@angular/animations": "^5.2.0",
    "@angular/cdk": "^5.2.0",
    "@angular/common": "^5.2.0",
    "@angular/compiler": "^5.2.0",
    "@angular/core": "^5.2.0",
    "@angular/fire": "^5.1.1",
    "@angular/forms": "^5.2.0",
    "@angular/http": "^5.2.0",
    "@angular/material": "^5.2.0",
    "@angular/platform-browser": "^5.2.0",
    "@angular/platform-browser-dynamic": "^5.2.0",
    "@angular/router": "^5.2.0",
    "angularfire2": "^5.0.0-rc.6.0",
    "core-js": "^2.4.1",
    "firebase": "^5.8.6",
    "rxjs": "^5.5.6",
    "tslib": "^1.9.0",
    "zone.js": "^0.8.19"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.13.0",
    "@angular/cli": "^7.3.5",
    "@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"
  }

ng --version提供:

@angular-devkit/architect         0.13.5
@angular-devkit/build-angular     0.13.5
@angular-devkit/build-optimizer   0.13.5
@angular-devkit/build-webpack     0.13.5
@angular-devkit/core              7.3.5
@angular-devkit/schematics        7.3.5
@angular/cdk                      5.2.5
@angular/cli                      7.3.5
@angular/fire                     5.1.1
@angular/material                 5.2.5
@ngtools/webpack                  7.3.5
@schematics/angular               7.3.5
@schematics/update                0.13.5
rxjs                              5.5.12
typescript                        2.5.3
webpack                           4.29.0
  

firebase --version   6.4.0

我尝试搜索stackoverflow并尝试了一些无效的方法:

npm uninstall firebase
npm install firebase@4.8.0
rm -rf node_modules
npm install

,或尝试使用最新的Firebase:

npm uninstall firebase
npm install firebase
rm -rf node_modules
npm install

也不起作用。

我真的会寻求帮助,

2 个答案:

答案 0 :(得分:1)

AngularFire已移至@angular/fire。在package.json中,您有"angularfire2": "^5.0.0-rc.6.0"(旧版本)和"@angular/fire": "^5.1.1"

阅读Angularfire文档,并确保使用兼容版本

答案 1 :(得分:0)

您需要安装package.json文件中定义的firebase依赖项:

例如:npm install firebase@4.3.0