I'm working on project where I'm using express in firebase functions to run server side rendering pages using handlebars, Everything working perfectly but when I use firestore admin sdk I get this error:
SyntaxError: Invalid or unexpected token
at Module._compile (internal/modules/cjs/loader.js:723:23)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
at Module.require (internal/modules/cjs/loader.js:692:17)
at require (internal/modules/cjs/helpers.js:25:18)
I'm using this code in my functions/index.js file
const functions = require('firebase-functions');
const express = require('express')
const engines = require('consolidate')
const cookieParser = require('cookie-parser')
const serviceAccount = require('./lendme360-firebase-adminsdk-easkh-d9130c0494.json');
var admin = require('firebase-admin')
admin.initializeApp({
credential: admin.credential.cert(serviceAccount)
})
const stripe = require('stripe')('xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx');
const db = admin.firestore()
const app = express()
app.engine('hbs', engines.handlebars)
app.set('views', './views')
app.use(cookieParser())
app.set('view engine', 'hbs')
...
...
...
...
...
exports.app = functions.https.onRequest(app)
Function is working properly but when try to const db = admin.firestore() gives me error I also tried emulators for both functions and firestore and still getting the same error
Please help me What I'm doing wrong here
Thanks in advance