angular / angularfire

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

[auth] auth is undefined on first click #2354

Closed atb00ker closed 3 years ago

atb00ker commented 4 years ago

Version info

Angular: 9.0.3 (Ivy) Firebase: 7.8.0 AngularFire: 6.0.0-rc.1 Other: OS: Debian Buster Browser: Mozilla Firefox 68.5.0esr npm: 6.13.7 node: v13.9.0

How to reproduce these conditions

Steps to set up and reproduce

Follow the tutorial here or any tutorial to setup authentication in a new project.

Debug output

Errors in the JavaScript console

ERROR TypeError: "firebase_app__WEBPACK_IMPORTED_MODULE_1__.auth is undefined"
    loginBegin auth.service.ts:27
    NavComponent_li_17_Template_a_click_1_listener nav.component.html:34
    Angular 10
core.js:5882:19

Expected behavior

I chick login button and login should work on first click. Instead of showing the error.

Actual behavior

I click login, I see the error on the console. Then I click the login button again, on second click, I am able to login.

atb00ker commented 4 years ago

P.S: I just tried with version 5 and everything worked -- It must be a change in version 6 branch! :smile:

ArtisanvsDev commented 4 years ago

I am not sure if this is related but I fix a similar issue by importing the auth module like this:

import { AngularFireAuth } from '@angular/fire/auth'; import { firebase } from '@firebase/app'; import '@firebase/auth';