firebase.auth不是一个函数 [英] firebase.auth is not a function

查看:100
本文介绍了firebase.auth不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有firebase和firebase-admin的Webpack。

I am using Webpack with firebase and firebase-admin.

要安装firebase,我跑了

To install firebase I ran

npm install --save firebase

我正在使用导入firebase,

I am importing firebase using,

import * as firebase from 'firebase/app'
import 'firebase/auth'

我也试过

import * as firebase from 'firebase'

我试过

const firebase = require('firebase')

正如网络入门指南中所述

当我尝试使用 firebase.auth()但是我收到错误

When I try to use firebase.auth() however I get an error


console.js:32 TypeError:firebase.auth不是函数

console.js:32 TypeError: firebase.auth is not a function

当我使用调试器检查 firebase 我看到它实际上是d oes没有 auth 功能:

When I use the debugger to inspect firebase I see that it in fact does not have an auth function:

> firebase
 {__esModule: true, initializeApp: ƒ, app: ƒ, Promise: ƒ, …}

如何使用webpack将auth()作为函数包含在内?

How can I get auth() included as a function using webpack?

谢谢。

编辑:
这是评论中问题的副本。该问题涉及一种方法,该方法是auth服务的成员,而不是auth服务本身。

This is not a duplicate of the question in the comment. That question refers to a method that is a member of the auth service, not the auth service itself.

推荐答案

好的,修好了这个通过删除我的 node_modules 目录并重新安装所有内容。

Ok, fixed this by deleting my node_modules directory and reinstalling everything.

我也是这样导入firebase:

Also I'm importing firebase like so:

import firebase from 'firebase'
require('firebase/auth')

我不知道。

¯\_(ツ)_/¯

这篇关于firebase.auth不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆