Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
timucincicek opened this issue Feb 3, 2023 · 21 comments

Comments

@timucincicek
Copy link

timucincicek commented Feb 3, 2023

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
Copy link

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

@lambirou
Copy link

lambirou commented Feb 3, 2023

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

"firebase": "~9.9.2",
"@angular/fire": "~7.4.1"

@Mocsa1974
Copy link

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
Copy link

BhattaRj commented Feb 3, 2023

I am also facing the same issue

@rbonestell
Copy link

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
Copy link

looegi commented Feb 3, 2023

Also facing this. Solved by downgrading to 7.4.1.

@Timebutt
Copy link

Timebutt commented Feb 3, 2023

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

@hittten
Copy link

hittten commented Feb 3, 2023

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
Copy link

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
Copy link

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

@llongoria
Copy link

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
Copy link

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

@hittten
Copy link

hittten commented Feb 3, 2023

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
Copy link

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
Copy link

Timebutt commented Feb 5, 2023

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
Copy link

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

@stephvarvar
Copy link

nevermind figured it out thank you

@kingjordan
Copy link

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
Copy link

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

@Timebutt
Copy link

Timebutt commented Feb 24, 2023

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
Copy link

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';

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests