前提・実現したいこと
angularとfirebaseでSPA作ってます
認証の方法としてgoogleアカウントでの認証を作りたいのですがコードの途中でエラーが出てしまいその解消法がわからないです
発生している問題・エラーメッセージ
モジュール '"firebase"' にはエクスポートされたメンバー 'auth' がありません。 'import auth from "firebase"' を使用するつもりでしたか?ts(2614)
該当のソースコード
typescript
1import { Injectable } from '@angular/core'; 2import { AngularFireAuth } from '@angular/fire/auth'; 3import * as firebase from 'firebase'; 4import { auth } from 'firebase' 5@Injectable({ 6 providedIn: 'root' 7}) 8export class AuthService { 9 10 constructor( 11 private afAuth: AngularFireAuth) { } 12 login() { 13 this.afAuth.signInWithPopup(new auth.GoogleAuthProvider()) 14 } 15} 16
このコードのimport部分**import { auth } from 'firebase'**でエラーが出てしまいました
試したこと
angularでfirebaseを使用する上で必要なパッケージなどの再インストール
typescript
1this.afAuth.signInWithPopup(new auth.GoogleAuthProvider()) 2上記を 3this.afAuth.signInWithPopup(new firebase.auth.GoogleAuthProvider()) 4
と書いてる
などの2点を試みました
補足情報(FW/ツールのバージョンなど)
参考文献1
参考文献2
上の二つの文献を参考にして改善を図ったのですが、なぜauthの部分でerrorになるのか見当もつかなかったのでお知恵を拝借したいです
最後になりますがこのような質問をするのに不慣れなもので、情報が足りない可能性がありますが平にご容赦願います
あなたの回答
tips
プレビュー