I'm trying to set an integration between Angular 8/Firestore and Stripe, following some tutorials. My config.ts file is:
import * as functions from 'firebase-functions';
import * as admin from 'firebase-admin';
admin.initializeApp();
// Initialize Cloud Firestore Database
export const db = admin.firestore();
const settings = { timestampsInSnapshots: true };
db.settings(settings);
// ENV Variables
export const stripeSecret = functions.config().stripe.secret;
// Export Stripe
import Stripe from 'stripe';
export const stripe = new Stripe(stripeSecret, {apiVersion: '2020-08-27' });
Everything looks right but when I'm trying to deploy it, displays the following message:
TypeError: admin.initializeApp is not a function
I've checked firebase-admin versions and also the way I've imported it, but I get the same error. How can I solve this?
UPDATE
I tried to change the way I've imported:
import { initializeApp } from 'firebase-admin';
initializeApp();
But I had another error:
SyntaxError: Named export 'initializeApp' not found. The requested module 'firebase-admin' is a CommonJS module, which may not support all module.exports as named exports. CommonJS modules can always be imported via the default export, for example using: import pkg from 'firebase-admin'; const { initializeApp } = pkg;