Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

166
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!