【问题标题】:Import Firebase auth in Angular not found找不到在 Angular 中导入 Firebase 身份验证
【发布时间】:2021-05-08 22:08:52
【问题描述】:
 import { auth } from 'firebase/app'; // not compiling

引发链接错误:

“在‘firebase/app’中找不到导出‘auth’”

版本:Angular:11.1.0、rxjs@6.6.3、firebase@8.2.5、firebase-tools@7.16.2


我卸载了@angularfire2、@types/firebase - 我认为它们可能会导致这个错误, 我对 angular 和 firebase 很陌生,并试图使 firebase google 身份验证正常工作,请帮忙!


【问题讨论】:

标签: angular firebase authentication firebase-authentication


【解决方案1】:

找到了解决办法:

import {firebase} from '@firebase/app';
import '@firebase/auth';

从这里:https://github.com/AnthonyNahas/ngx-auth-firebaseui/commit/73ca9b986cf0fa300898f3890e8ec4440005d7d9

【讨论】:

    【解决方案2】:

    首先你在环境中导入你所有的firebase配置(无论你想导入什么,因此以写入方式包含它)。

    environment.ts

    导出 const 环境 = {
    生产:假,
    火力基地配置:{
    apiKey: "",
    authDomain: "a
    aa
    .firebaseapp.com",
    项目 ID:“social-43-23-1212,
    storageBucket: "social-app-df**131.appspot.com",
    messagesSenderId: "2234gsesert",
    appId: "
    *********",
    测量 ID:“345334535”
    }
    };

    现在在 app.module.ts 中添加 firebase

    从“@angular/fire”导入 { AngularFireModule };
    从“@angular/fire/auth”导入 { AngularFireAuthModule };

    @NgModule({
    进口:[
    AngularFireModule.initializeApp
    (environment.firebaseConfig, '应用程序'),
    ]
    });

    【讨论】:

    • 嗨,谢谢,我这样做了,但仍然存在相同的错误..
    猜你喜欢
    • 2022-07-10
    • 1970-01-01
    • 2017-06-28
    • 2020-05-20
    • 2021-05-29
    • 2017-02-24
    • 2018-04-15
    • 2020-06-01
    • 2021-05-12
    相关资源
    最近更新 更多