angular / angularfire

Angular + Firebase = ❤️
https://firebaseopensource.com/projects/angular/angularfire2
MIT License
7.69k stars 2.19k forks source link

@angular/fire throws Error: Module not found: Error: Default condition should be last one #3316

Closed timucincicek closed 1 year ago

timucincicek commented 1 year ago

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?

image 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 image

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.

See the stacloverflow ticket: https://stackoverflow.com/questions/75335661/angular-fire-throws-error-module-not-found-error-default-condition-should-be

google-oss-bot commented 1 year ago

This issue does not seem to follow the issue template. Make sure you provide all the required information.

lambirou commented 1 year ago

I solved the problem with a downgrade of the 2 packages.

"firebase": "~9.9.2",
"@angular/fire": "~7.4.1"
Mocsa1974 commented 1 year ago

I have the same problem with fire 7.5.0 and firebase 9.17.0 Downgrade firebase to 9.16.0 works fine. Waiting for solution

BhattaRj commented 1 year ago

I am also facing the same issue

rbonestell commented 1 year ago

My team is also facing this issue, with complications downgrading because our angular app uses --legacy-peer-deps so we're spending the day today unwinding dependencies and trying to override where necessary... Really disappointed this happened with properly version dependencies.

looegi commented 1 year ago

Also facing this. Solved by downgrading to 7.4.1.

Timebutt commented 1 year ago

Feels like this upstream PR might be the culprit, fix incoming.

hittten commented 1 year ago

I think that I found the problem:

Package "firebase": 9.17.0 won't work Package "firebase": 9.16.0 is working

This is my package.json file:

{
  "name": "test",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "watch": "ng build --watch --configuration development",
    "test": "ng test"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^15.1.0",
    "@angular/cdk": "^15.1.3",
    "@angular/common": "^15.1.0",
    "@angular/compiler": "^15.1.0",
    "@angular/core": "^15.1.0",
    "@angular/fire": "^7.5.0",
    "@angular/forms": "^15.1.0",
    "@angular/material": "^15.1.3",
    "@angular/platform-browser": "^15.1.0",
    "@angular/platform-browser-dynamic": "^15.1.0",
    "@angular/router": "^15.1.0",
    "@angular/service-worker": "^15.1.0",
    "firebase": "~9.16.0",
    "rxjs": "~7.8.0",
    "tslib": "^2.3.0",
    "zone.js": "~0.12.0"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "^15.1.3",
    "@angular/cli": "~15.1.3",
    "@angular/compiler-cli": "^15.1.0",
    "@types/jasmine": "~4.3.0",
    "jasmine-core": "~4.5.0",
    "karma": "~6.4.0",
    "karma-chrome-launcher": "~3.1.0",
    "karma-coverage": "~2.2.0",
    "karma-jasmine": "~5.1.0",
    "karma-jasmine-html-reporter": "~2.0.0",
    "typescript": "~4.9.4"
  }
}

You can easily recreate the error simply by changing "firebase": "~9.16.0", to "firebase": "~9.17.0", then delete the package-lock.json file and run "npm install"

NOTE: Be aware that if you just install @angular/fire, it will install below the latest firebase package, but you can work around this, simply by adding a specific version of firebase@9.16.0

Conclusion: is a problem with firebase@9.17.0 package

llongoria commented 1 year ago

I have the same issue. The angular/fire version is 7.5.0 and firebase version 9.17.0.

If I downgrade to firebase 9.16.0, works fine.

TeePlunder commented 1 year ago

I am also facing the same issue. Even downgrading is not working for me :worried:

llongoria commented 1 year ago

When you change the firebase version, check the next steps:

From: "firebase": "^9.16.0",

To: "firebase": "9.16.0",

You can see that i delete the '^' simbol too.

TeePlunder commented 1 year ago

Is not working for me, I'm still getting that error :/

hittten commented 1 year ago

If you change your package.json file, you have to put ~9.16.0 why? Read this https://docs.npmjs.com/about-semantic-versioning#using-semantic-versioning-to-specify-update-types-your-package-can-accept

Also you need to delete the "package-lock.json" file and the "node_modules" folder. And then finally run "npm install"

TeePlunder commented 1 year ago

I was a noob xD. I used yarn install but only deleted the package-lock.json and not the yarn.lock 😐. Now it works, thanks! 😃

Timebutt commented 1 year ago

Fixed with the release of firebase version 9.17.1. They also update the release notes of 9.17.0 to notify people of the bug it contains. This ticket can be closed AFAIK!

stephvarvar commented 1 year ago

new to this... can someone please tell me how to downgrade in vs npm?

stephvarvar commented 1 year ago

nevermind figured it out thank you

kingjordan commented 1 year ago

my issue was

Fixed with the release of firebase version 9.17.1. They also update the release notes of 9.17.0 to notify people of the bug it contains. This ticket can be closed AFAIK!

My issue was resolved with update. I am now using 7.5.0 and the errors are gone

daheadcracker commented 1 year ago

When can we expect a fix of this in the official npm package of @angular/fire? It's still in 7.5.0.

Timebutt commented 1 year ago

The issue happens because of an incorrect version of firebase, not @angular/fire. Make sure to install version 9.17.1 of firebase (you can check which version you have installed by running npm list firebase or yarn list firebase).

noahcorrea commented 11 months ago

Im my case I was importing from wrong path:

Wrong import: import { Messaging, onMessage, getToken } from '@angular/fire/messaging/firebase';

This is correct: import { Messaging, onMessage, getToken } from '@angular/fire/messaging';