firebase.auth is not a function

前端 未结 18 1040
孤城傲影
孤城傲影 2020-11-28 10:30

I am using Webpack with firebase and firebase-admin.

To install firebase I ran

npm install --save firebase

I am importing firebase

18条回答
  •  余生分开走
    2020-11-28 10:59

    I ran into this as well. My issue was the npm module @firebase was installed as well as the firebase module. When I required firebase in my JavaScript code with ‘require(“firebase”)’, webpack bundled @firebase instead for some reason.

    @firebase doesn’t include auth, database etc. by default...it’s modular so you can require them separately. Consequently I received the above error when I tried calling auth().

    To fix it you can remove @firebase...or just add the full path to the correct firebase when you require it like

    require(‘/path/to/node_modules/firebase/firebase.js’)

提交回复
热议问题