firebase.auth 不是函数 [英] firebase.auth is not a function
问题描述
我正在使用带有 firebase 和 firebase-admin 的 Webpack.
I am using Webpack with firebase and firebase-admin.
为了安装firebase,我跑了
To install firebase I ran
npm install --save firebase
我正在使用,
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 is not a function
console.js:32 TypeError: firebase.auth is not a function
当我使用调试器检查 firebase
时,我发现它实际上没有 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?
谢谢.
推荐答案
好的,通过删除我的 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屋!