How to connect Firebase to a Node.JS project?

Initially developed an application without NodeJS. But then I connected Node.JS, because I need to take all the collections in the database using listCollections(). Before connecting Node Firebase, I initialized in the Firebase.js file. Now I have added Node.JS and made the firebase-admin connection as shown in the example. But when starting the server, the error is FirebaseAppError: The default Firebase app does not exist. Make sure you call initializeApp() before using any of the Firebase services. How t

// server.js

const express = require("express");
const admin = require("firebase-admin");
const db = admin.firestore();
const app = express();
const PORT = 3000;

app.use(express.static("public"));

app.get("/", (req, res) => {
  res.send("Hello World!");
});

app.listen(PORT, () => console.log(`Server listening on port: ${PORT}`));

db.listCollections()
  .then((snapshot) => {
    snapshot.forEach((snaps) => {
      console.log(snaps["_queryOptions"].collectionId); // LIST OF ALL COLLECTIONS
    });
  })
  .catch((error) => console.error(error));

// firebase.js

const firebaseConfig = {
  apiKey: "...",
  authDomain: "..",
  projectId: "...",
  storageBucket: "...",
  messagingSenderId: "...",
  appId: "...",
  measurementId: "...",
};

firebase.initializeApp(firebaseConfig);
var db = firebase.firestore();

o properly connect Firebase?