Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

238
Visualizações
firebase.auth is not a function

I am using Webpack with firebase and firebase-admin.

To install firebase I ran:

npm install --save firebase

I am importing firebase using:

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

I also tried:

import * as firebase from 'firebase'

And I tried:

const firebase = require('firebase')

As suggested in web get started guide.

However, when I try to use firebase.auth() I get an error:

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

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: ƒ, …}

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

over 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

I fixed this by deleting my node_modules directory and reinstalling everything.

Also I'm importing firebase like so:

import firebase from 'firebase'
require('firebase/auth')
over 4 years ago · Santiago Trujillo Relatório

0

The problem wasn't with the node_modules, it was with the way that you were importing the component.

When you export a component ES6 way, you normally do export default () => { console.log('default component export'); };

default is the keyword here, when you import a component ES6 way like import firebase from 'firebase' it's grabbing the default property from the exported object.

Keeping in mind the above example, here's what you've done wrong.

Using ES6:

import * as firebase from 'firebase'

console.log(firebase.auth) // Undefined
console.log(firebase.default.auth) // Function

Using ES5:

var firebase = require('firebase')

console.log(firebase.auth) // Undefined
console.log(firebase.default.auth) // Function

Note the .default

over 4 years ago · Santiago Trujillo Relatório

0

I kept getting an error that said

"TypeError: firebase.auth is not a function"

I got the auth object to appear and the thing I did differently was install the modules in a different order.

The first time I installed the modules (this is when the auth object wasn't appearing):

// this seems to confuse things with the auth object when installed in this order
$ npm install firebase-admin --save
$ npm install firebase --save

I deleted the npm folder and started from scratch although this time I reversed the installation order:

// for some reason this worked and now I can access the auth object
$ npm install firebase --save
$ npm install firebase-admin --save

I didn't do anything else. I simply reversed the installation order by installing firebase first and firebase-admin second.

I hope this works for other people.

You can read more about it here

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda