10

I've been using AngularCrashlytics(from @angular/fire) for a while interestingly since this morning I became unable to get either build or ng serve which throws error as below.Can someone help me to get rid of this?

enter image description here

On the app.module I've already added @angular/fire releated configuration steps as below(taken from https://github.com/angular/angularfire/blob/master/docs/analytics/getting-started.md)

import { AngularFireModule } from '@angular/fire/compat';
import { AngularFireAnalyticsModule } from '@angular/fire/compat/analytics';

imports:[
AngularFireModule.initializeApp(environment.Tools.Firebase)//firebase releated config,
AngularFireAnalyticsModule
]

I have configuration mentioned as below, with ng version enter image description here

Dependency versions from package.json

"firebase": "^9.14.0",
"@angular/fire": "^7.4.1"

Additional Note : Already cloned project from scratch many times have tried deleting node modules folder and npm install besides tried to upgrade both firebase and @angular/fire to the latest versions which didn't fix the issue.

Zahir Masoodi
  • 546
  • 7
  • 23
Timuçin Çiçek
  • 1,516
  • 3
  • 14
  • 39
  • 3
    No idea what is the root cause, but in my project i got the same problem today as well. Yesterday all was working fine, and today i run npm update, and get the error. One thing that my help you, revert the "@angular/fire": "^7.4.1" to "@angular/fire": "7.2.1". I know this is not best solution, but it may help – Nikola.grancharov Feb 03 '23 at 13:38
  • 2
    I got the same issue today but downgrading @angular/fire to 7.2.1 doesn't fix the issue either. – Vladimir Vladimirov Feb 03 '23 at 13:56
  • 1
    Thanks to @Nikola.grancharov 's answer I tried to downgrade @angular/fire to 7.2.1 first all errors disappeared except Can't resolve 'rxfire/auth' in ... . To resolve that I had to install it via npm i rxfire then totally fine – Timuçin Çiçek Feb 03 '23 at 14:09
  • 1
    downgrade to 7.4.1 angular/fire solved for me. this was with a new demo project created today with ng new and ng add @angular/fire, i did have to delete node_modules and package.lock.json and npm i – J King Feb 03 '23 at 20:32
  • same for [react](https://stackoverflow.com/q/75337593/14047838) – Zahir Masoodi Feb 04 '23 at 06:09

4 Answers4

2

This morning I updated Angular from 15.1.2 to 15.1.3:

enter image description here

This threw 34 errors, all involving AngularFire:

Error: export 'GoogleAuthProvider' (imported as 'GoogleAuthProvider') was not found in '@angular/fire/auth'

./node_modules/@angular/fire/fesm2015/angular-fire-analytics.js:7:0-47 - Error: Module not found: Error: Default condition should be last one

I tried using overrides in package.json but npm install refused to run the overrides, throwing EOVERRIDE errors. npm install --force didn't help.

I fixed it by not using overrides but instead changing "^15.0.0" to "15.1.2" and then running npm install --force.

I don't understand why overrides didn't work. I might ask a question about this.

I'll wait until a new version of AngularFire is released before updating to the latest Angular.

Thomas David Kehoe
  • 10,040
  • 14
  • 61
  • 100
  • Thank You! This fixed the issue for me. What does "^" [caret](https://stackoverflow.com/a/22345808/14047838) mean in npm dependencies. – Zahir Masoodi Feb 04 '23 at 06:24
  • 1
    The ^ caret means "and updates in this version." "^15.0.0" will update with "npm update" to 15.0.1, 15.1.0, etc. but not to 16.0.0. – Thomas David Kehoe Feb 04 '23 at 22:09
  • My question about overrides is here: https://stackoverflow.com/questions/75340053/confused-about-overrides-in-package-json/75341354. tl;dr don't use overrides to revert to an older version. Overrides are for managing the dependencies of dependencies. – Thomas David Kehoe Feb 04 '23 at 22:11
  • I updated Angular to 15.2.0, everything works. – Thomas David Kehoe Feb 25 '23 at 16:36
1

I guess the issue comes from the dependency here: node_modules/@angular/fire/package.json

"dependencies": {
  "firebase": "^9.8.0",

As stated here: https://github.com/firebase/firebase-js-sdk/issues/7005#issuecomment-1415807037

Removing the ^ within the version solved it for me.

I did this in my projects package.json to override it:

{
  "name": "myproject",
  "version": "0.0.0",
  "scripts": ...
  "dependencies": ...
  "devDependencies": {
    ...
  },  
  "overrides": {
    "@angular/fire": {
      "firebase": "9.8.0"
    }
  },

Then run "npm install" to apply this.

Should be fixed in the next release of "@angular/fire".

1

In package.json add this code:

  "overrides": {
    "@angular/fire": {
      "firebase": "9.8.1"
    }
  }

version from fire is: "@angular/fire": "^7.4.1" and node 16.14.2 with npm 8.5.0 Delete rm -r node_modules package-lock.json .angular Only npm not yarn

0

issue with angular fire
https://www.bezkoder.com/angular-15-firestore-crud/
To get rid of these errors, you must update the tsconfig.json file.

 ...
  "compilerOptions": {
 ...
  "skipLibCheck": true.  //add this line!!!!!!!
 },
 ...
avariant
  • 2,234
  • 5
  • 25
  • 33
tvas
  • 11
  • 1