I am trying to update a Firebase Cloud Function that I havent touched for a year. Deployment went without issues back then.
Here is my setup: I have a root index.ts file, and functions are organized into folders. root index.ts
import {initializeApp} from "firebase-admin";
// Initialize Firebase Admin
initializeApp();
export {notifyNewMessages} from "./notify_new_messages";
export {onUpdateUsers, onUpdateUserRatings} from "./on_update/index";
export {onUninstall} from "./on_uninstall/index";
and notifyNewMessages file starts like this
import {FirebaseError, firestore, messaging} from "firebase-admin";
import * as functions from "firebase-functions";
import i18n from "./localization";
import {Ask, Device, User} from "./models";
import DocumentSnapshot = firestore.DocumentSnapshot;
const fcm: messaging.Messaging = messaging();
Could this separated root file cause this problem?
Cheers,
CodePudding user response:
It looks like you are using ES Modules, and as firebase has moved to modular SDK namespace versions require some modifications so try the following:
import * as admin from 'firebase-admin';
const app: admin.app.App = admin.initializeApp();
You can go through this docs for other changes to be made.