【问题标题】:Firebase Auth TypeError: module is undefinedFirebase Auth TypeError:模块未定义
【发布时间】:2019-06-19 03:08:20
【问题描述】:

我想设置带有 react 的 Firebase Auth 预构建 UI 我从github复制了代码 我收到此错误:

TypeError:firebase__WEBPACK_IMPORTED_MODULE_2___default.a.auth 未定义

Screenshot of my Error

https://github.com/firebase/firebaseui-web-react

我使用 VScode 和 node.js 安装包

import React from 'react';
import StyledFirebaseAuth from 'react-firebaseui/StyledFirebaseAuth';
import firebase from 'firebase';

    uiConfig = {
        // Popup signin flow rather than redirect flow.
        signInFlow: 'popup',
        // We will display Google and Facebook as auth providers.
        signInOptions: [
          firebase.auth.GoogleAuthProvider.PROVIDER_ID,
          firebase.auth.FacebookAuthProvider.PROVIDER_ID
        ],
        callbacks: {
          // Avoid redirects after sign-in.
          signInSuccessWithAuthResult: () => false
        }
      };

【问题讨论】:

    标签: reactjs firebase firebase-authentication


    【解决方案1】:

    尝试同时导入 firebase 和您要使用的特定软件包。我在我的应用程序中使用“auth”包时遇到了同样的问题,但是在通用导入之后专门添加它,就可以了:

    import * as firebase from "firebase/app";
    import "firebase/auth";
    

    您可以在official documentation查看。

    【讨论】:

    • 是的,我试过了,但问题还是一样。出于某种原因,它说身份验证未定义
    • 谢谢。这个答案也适用于 firebaseui。 import * as firebaseui from 'firebaseui'
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-09-16
    • 2011-11-20
    相关资源
    最近更新 更多