Angular9:目标入口点“ @ angular / fire / auth”中的错误缺少相关性

时间:2020-04-09 21:03:30

标签: angular firebase angularfire angular9 angular-cli-v9

当我运行npm run start时,出现有关firebase的以下错误。

技术:Angular版本9,Firebase,Firestore,Geofirestore Angular CLI。

错误

ERROR in The target entry-point "@angular/fire/auth" has missing dependencies:
 - firebase/auth
 - firebase/app

要注意的依赖性:

"@angular/cli": "~9.1.1",
"@angular/core": "~9.1.1",
"@angular/fire": "^5.1.1",
"firebase": "5.10.1",
"geofirestore": "3.2.3",

打包json

{
  "name": "project",
  "version": "1.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve -o",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e",
  },
  "private": true,
  "dependencies": {
    "@agm/core": "^1.1.0",
    "@angular/animations": "~9.1.1",
    "@angular/cdk": "^9.2.0",
    "@angular/common": "~9.1.1",
    "@angular/compiler": "~9.1.1",
    "@angular/core": "~9.1.1",
    "@angular/fire": "^5.1.1",
    "@angular/forms": "~9.1.1",
    "@angular/material": "^9.2.0",
    "@angular/platform-browser": "~9.1.1",
    "@angular/platform-browser-dynamic": "~9.1.1",
    "@angular/platform-server": "^9.1.1",
    "@angular/pwa": "^0.901.1",
    "@angular/router": "~9.1.1",
    "@angular/service-worker": "^9.1.1",
    "@babel/cli": "^7.8.4",
    "@babel/core": "^7.9.0",
    "@babel/preset-env": "^7.9.5",
    "@fortawesome/fontawesome-free": "^5.13.0",
    "@hackages/ngxerrors": "^8.0.0",
    "@kolkov/angular-editor": "^1.1.2",
    "@nguniversal/express-engine": "^9.1.0",
    "@nguniversal/module-map-ngfactory-loader": "^8.2.6",
    "@ngx-meta/core": "^8.0.2",
    "@ngx-pwa/offline": "^9.1.0",
    "@sentry/browser": "^5.15.4",
    "angular-google-map": "0.0.2",
    "animate.css": "^3.7.2",
    "aos": "^2.3.4",
    "basscss": "^8.1.0",
    "basscss-sass": "^4.0.0",
    "chart.js": "^2.9.3",
    "core-js": "^3.6.4",
    "express": "^4.17.1",
    "firebase": "5.10.1",
    "fs-extra": "^9.0.0",
    "geofirestore": "3.2.3",
    "http-server": "^0.12.1",
    "latlon-geohash": "^2.0.0",
    "lodash": "^4.17.15",
    "lozad": "^1.14.0",
    "moment": "^2.24.0",
    "ng2-truncate": "^1.3.17",
    "ngx-google-places-autocomplete": "^2.0.4",
    "ngx-prevent-double-submission": "^0.1.0",
    "rxjs": "~6.5.4",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^0.901.1",
    "@angular/cli": "~9.1.1",
    "@angular/compiler-cli": "~9.1.1",
    "@angular/language-service": "~9.1.1",
    "@types/jasmine": "~3.5.0",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "^12.11.1",
    "codelyzer": "^5.1.2",
    "jasmine-core": "~3.5.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.4.1",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage-istanbul-reporter": "~2.1.0",
    "karma-jasmine": "~3.0.1",
    "karma-jasmine-html-reporter": "^1.4.2",
    "protractor": "~5.4.3",
    "ts-node": "~8.3.0",
    "tslint": "~6.1.0",
    "typescript": "~3.8.3"
  }
}

错误屏幕抓取:

enter image description here

使用Firebase / firestore和Angular 9从我的应用中获取的代码:

import * as firebase from 'firebase/app';
import * as _geoHash from 'latlon-geohash';
import { AngularFireDatabase } from '@angular/fire/database';
import { AngularFirestore } from '@angular/fire/firestore';
import { Injectable } from '@angular/core';
import { Observable, from, of } from 'rxjs';
import { GeoFirestore } from 'geofirestore';
import { map, take } from 'rxjs/operators';

import { FirebaseService } from '../services/firebase.service';
import { JobModel } from '../models/job.model';
import { StorageService } from '../services/storage.service';
import { UserService } from '../services/user.service';
import { UtilityService } from '../services/utility.service';

@Injectable()
export class JobService extends FirebaseService {
  public geo: any;
  public geofirestore: GeoFirestore;

  constructor(
    public angularFireDatabase: AngularFireDatabase,
    private angularFirestore: AngularFirestore,
    public storageService: StorageService,
    private userService: UserService,
    private utilityService: UtilityService
  ) {
    super(angularFireDatabase);

    const firestore = firebase.firestore();
    firestore.settings({ });
    this.geofirestore = new GeoFirestore(firestore);
  }

  public getCount(): any {
    const adzuna = firebase.firestore().collection('jobsCount').doc('adzuna');
    const hired = firebase.firestore().collection('jobsCount').doc('hired');

    return from(Promise.all([adzuna.get(), hired.get()])
      .then((querySnapshot) => {
        return { adzuna: querySnapshot[0].data(), hired: querySnapshot[1].data() };
      })
    );
  }
}

7 个答案:

答案 0 :(得分:39)

有同样的问题。将我的package.json与我的另一个前几天工作的项目进行了比较。

我发现Firebase软件包不存在。所以我只是将其复制进来,

“ firebase”:“ ^ 7.13.2”,

运行

npm安装

似乎可行:

package.json:

"dependencies": {
    "@angular/animations": "~9.1.0",
    "@angular/cdk": "^9.2.0",
    "@angular/common": "~9.1.0",
    "@angular/compiler": "~9.1.0",
    "@angular/core": "~9.1.0",
    "@angular/fire": "^6.0.0",
    "@angular/forms": "~9.1.0",
    "@angular/material": "^9.2.0",
    "@angular/platform-browser": "~9.1.0",
    "@angular/platform-browser-dynamic": "~9.1.0",
    "@angular/router": "~9.1.0",
    "firebase": "^7.13.2",
    "rxjs": "~6.5.4",
    "tslib": "^1.10.0",
    "zone.js": "~0.10.2"
  },

现在我看到您有一个较旧的版本,也许可以解决该问题进行更新?

答案 1 :(得分:13)

TL; DR
您需要两个软件包(@angular/firefirebase)才能正常运行 您的应用,然后使用firebase / firestore。
使用ng add @angular/firenpm install firebase

安装它们

说明:

我在为我的应用程序投放服务时遇到此错误。

ERROR in The target entry-point "@angular/fire" has missing dependencies:
 - firebase/app

此错误的原因:正确的 firebase角度设置 需要两个软件包@angular/firefirebase。我仅使用ng add @angular/fire安装了其中之一。为了成功运行我的项目,我必须使用firebase安装npm install firebase软件包,并且此后可以正常工作。

答案 2 :(得分:6)

只需在您的项目中更新/安装Firebase(本地,而不是全局)。使用终端转到项目文件夹并执行:

npm install firebase@latest

npm的当前版本默认使用--save标志,因此它将自动更改package.json。

答案 3 :(得分:1)

在您的应用程序中简单安装firebase。

npm install firebase --save

答案 4 :(得分:0)

我必须面对同样的错误。

我刚刚安装了cli cli 8版本。 我以前的角度cli是10。

step 1> npm cache clean --force
step 2> npm uninstall -g @angular/cli
step 3> npm cache clean --force
step 4> npm install -g @angular/cli@8.1.0
step 5> ng new project_name
step 6> ng add @angular/fire firebase

希望一切都很好。

答案 5 :(得分:0)

运行命令

npm i firebase@7.24.0

答案 6 :(得分:0)

安装 Firebase,如下所示,也对我有用。

C:**Users**z0044wmy**Desktop**PMI APP GIT**pmi-app**GENERATED_REPORTS
C:\Users\z0044wmy\Desktop\PMI APP GIT\pmi-app\GENERATED_REPORTS