Home > database >  Firebase throws Error: Module not found: Error: Default condition should be last one
Firebase throws Error: Module not found: Error: Default condition should be last one

Time:02-06

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

CodePudding user response:

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.

CodePudding user response:

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".

CodePudding user response:

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

CodePudding user response:

Thank u guys i downgrae th @angular/fire to "7.4.1" and it works again. I don't know why it happend yet, but i can work on my project again :-)

  • Related