Angularfire: [auth] auth is undefined on first click

Created on 16 Mar 2020  路  2Comments  路  Source: angular/angularfire

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.

Most helpful comment

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

All 2 comments

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

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

Was this page helpful?
0 / 5 - 0 ratings