mod.hasOwnProperty is not a function at extract Triggers firebase tools javascript

Viewed 526

TypeError: mod.hasOwnProperty is not a function at extractTriggers (/usr/local/lib/node_modules/firebase-tools/lib/extractTriggers.js:5:17) at extractTriggers (/usr/local/lib/node_modules/firebase-tools/lib/extractTriggers.js:22:17) at /usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:589:38 at Generator.next () at fulfilled (/usr/local/lib/node_modules/firebase-tools/lib/emulator/functionsEmulatorRuntime.js:4:58) at at process._tickCallback (internal/process/next_tick.js:189:7) at Function.Module.runMain (module.js:696:11) at startup (bootstrap_node.js:204:16) at bootstrap_node.js:625:3 ⚠ Your function was killed because it raised an unhandled error.

here is package.json

{
  "name": "firebase-functions-es6-example",
  "version": "1.0.0",
  "description": "Use ES6 to develop Cloud Functions for Firebase today!",
  "license": "MIT",
  "devDependencies": {
    "@babel/cli": "^7.4.4",
    "@babel/core": "^7.4.5",
    "@babel/node": "^7.4.5",
    "@babel/plugin-proposal-object-rest-spread": "^7.4.4",
    "@babel/plugin-transform-runtime": "^7.4.4",
    "@babel/preset-env": "^7.4.5",
    "rimraf": "^2.6.2"
  },
  "scripts": {
    "deploy": "npm run package-functions && firebase serve --only functions,hosting",
    "prepackage-functions": "rimraf functions",
    "package-functions": "babel 'functionsES6' --out-dir 'functions' --presets=@babel/env --plugins=@babel/plugin-proposal-object-rest-spread,@babel/plugin-transform-runtime --copy-files --ignore 'node_modules'",
    "postpackage-functions": "cd functions && npm i"
  },
  "dependencies": {
    "@babel/runtime": "^7.4.5",
    "firebase-functions": "^3.0.2"
  }
}
1 Answers
import * as admin from 'firebase-admin'
  admin.initializeApp({
    credential: admin.credential.applicationDefault(),
    databaseURL: "https://<DATABASE_NAME>.firebaseio.com"
  });
  const db = admin.firestore();

You can't use export const "db" you'll receive that error. Try to remove the "export"

Related