Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error parsing triggers Cannot find module when deploying firebase function

Tags:

firebase

I am implementing a firebase function endpoint that requires I authenticate with two different projects. Information found on SO and other sources suggest this

import * as functions from 'firebase-functions'; 
import * as admin from 'firebase-admin';

const serviceAccountSource = require('./source.json');
const serviceAccountTarget = require('./target.json');

const sourceAdmin = admin.initializeApp({
  credential: admin.credential.cert(serviceAccountSource)
})
const targetAdmin =  admin.initializeApp({
  credential: admin.credential.cert(serviceAccountTarget)
s}, "destination")

Where source.json and target.json are files storing the serviceAccount credentials (JSON) obtained from the Project Settings => Generate New Private Key.

My folder structure is as follows

functions/
   index.ts
   source.json
   target.json

Running the following

npm run-script lint

produces no errors, however when I run

firebase deploy --only functions

I get

Error: Error parsing triggers: Cannot find module './source.json'

Firebase admin / functions versions as follows

"firebase-admin": "7.0.0",
"firebase-functions": "^2.2.0"

Typescript

"typescript": "^3.2.2"

Any ideas as what is causing the error.

like image 257
julianH Avatar asked Dec 23 '22 00:12

julianH


1 Answers

If you are using Typescript try moving your source.json to the lib folder.

like image 184
BigBen3216 Avatar answered Jun 14 '23 17:06

BigBen3216