LoginSignup

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

AngularでFirebaseAuthenticationを使いたい

解決したいこと

Angularを学習中、某ハンズオン内でFirebaseを利用しています。
Authentication機能を使いたいのですが、importできずに困っています。

インポート文
import { auth } from 'firebase';

現在の環境は以下の通りです。
"@angular/fire": "^6.0.4"
"firebase": "^8.0.0"
=>同じような作業をしている方のバージョンに合わせただけです。
https://github.com/firebase/firebase-js-sdk/issues/4023

最新のバージョン
"@angular/fire": "^6.1.5"
"firebase": "^8.6.8"
やハンズオン内にされている掲載のバージョン
"@angular/fire": "^6.0.0-rc.2"
でも同じ警告文が表示されます。

発生している問題・エラー

モジュール”firebase"にはエクスポートされたメンバー'auth'がありません。ts(2614)

以下、コード全文

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

@Injectable({
  providedIn: 'root',
})
export class AuthService {
  user$ = this.afAuth.user;
  constructor(private afAuth: AngularFireAuth) {}
  login() {
    this.afAuth
      .signInWithPopup(new auth.GoogleAuthProvider())
      .then((result) => {
        console.log(result);
      });
  }
  logout() {
    this.afAuth.signOut();
  }
}

自分で試したこと

Angular公式からそれぞれ対応するバージョンにダウングレードしてみたり、import文を
import auth from 'firebase/firebase-auth';
import { auth } from 'firebase/app';
import 'firebase/app';
など、試しましたが解決に至りませんでした。

知識不足で情けないです。お恥ずかしい話ですがこの問題に時間をかけすぎてしまっているため、ご助言頂けますと幸甚です。

0

No Answers yet.

Your answer might help someone💌