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

167
Visualizações
Express with Firebase require() throws error

I have an Express application that I am trying to connect to Firebase.

My console is currently throwing this error:

C:\Users\Tyler\Desktop\Dev\food-bank\app.cjs:19
const firebase = initializeApp(firebaseConfig);
                 ^

TypeError: initializeApp is not a function
    at Object.<anonymous> (C:\Users\Tyler\Desktop\Dev\food-bank\app.cjs:19:18)
    at Module._compile (node:internal/modules/cjs/loader:1095:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1124:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:816:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:79:12)
    at node:internal/main/run_main_module:17:47
[nodemon] app crashed - waiting for file changes before starting...

The offending code is here:

let initializeApp = require('./node_modules/@firebase/app');

I don't want to change my package.json to use import statements. The Firebase docs have import module statements but because I'm using Express I want to use the require statements.

How can I fix this?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I think you're simply missing the destructuring brackets in the require statement:

let { initializeApp } = require('./node_modules/@firebase/app');

Also, normally you should simply be able to require('@firebase/app') and not specify the relative path to packages inside node_modules:

    let { initializeApp } = require('@firebase/app');
about 4 years ago · Juan Pablo Isaza 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