I am trying to import the Firebase Admin SDK in my TypeScript (Nest.js) application.
let serviceAccount = require("../../creds.json");
console.log(serviceAccount);
const firebase = require("firebase");
firebase.initializeApp(environment.firebase);
admin.initializeApp({
credential: admin.credential.cert(serviceAccount),
databaseURL: "projectid"
});
But when I try and build the application I get the following error.
ERROR in ./node_modules/@google-cloud/firestore/src/v1beta1/firestore_client.js
Module not found: Error: Can't resolve './firestore_client_config' in '/home/jaybell/trellis-server/trellis/node_modules/@google-cloud/firestore/src/v1beta1'
@ ./node_modules/@google-cloud/firestore/src/v1beta1/firestore_client.js 28:17-53
@ ./node_modules/@google-cloud/firestore/src/v1beta1/index.js
@ ./node_modules/@google-cloud/firestore/src/index.js
@ ./src/server/main.server.ts
ERROR in ./node_modules/google-gax/lib/operations_client.js
Module not found: Error: Can't resolve './operations_client_config' in '/home/jaybell/trellis-server/trellis/node_modules/google-gax/lib'
@ ./node_modules/google-gax/lib/operations_client.js 30:17-54
@ ./node_modules/google-gax/index.js
@ ./node_modules/@google-cloud/firestore/src/v1beta1/index.js
@ ./node_modules/@google-cloud/firestore/src/index.js
@ ./src/server/main.server.ts
ERROR in ./node_modules/google-gax/index.js
Module not found: Error: Can't resolve './package' in '/home/jaybell/trellis-server/trellis/node_modules/google-gax'
@ ./node_modules/google-gax/index.js 65:18-38
@ ./node_modules/@google-cloud/firestore/src/v1beta1/index.js
@ ./node_modules/@google-cloud/firestore/src/index.js
@ ./src/server/main.server.ts
I have tried to search up any connection between the admin sdk and the google-cloud firestore package but nothing has shown up. I tried to include the firestore library and initialize it as well but this error still shows up.
I included the admin sdk exactly as in the firebase docs with
import * as admin from 'firebase-admin';
after installing with
yarn add firebase-admin
I know the firebase admin sdk can communicate with firestore but unsure of why it would be throwing this error during initialization.
It might have something to do with my project including both a front end and back end component that are compiled together, Node server that serves an angular site. Could the firebase admin sdk be being compiled with the front end possibly causing this error?
Any thoughts?