firebase-functions: Error occurred while parsing your function triggers.

node --version
v8.9.4

npm --version
5.6.0

firebase --version
3.17.4

firebase deploy --only functions

=== Deploying to ‘xxxxxx’…

i deploying functions Running command: npm --prefix $RESOURCE_DIR run lint

functions@ lint /Users/xx/Documents/Drive/AppDev/firebase/xxxx/functions eslint .

✔ functions: Finished running predeploy script. i functions: ensuring necessary APIs are enabled… ✔ functions: all necessary APIs are enabled i functions: preparing functions directory for uploading…

Error: Error occurred while parsing your function triggers.

ReferenceError: firebase is not defined at Object.<anonymous> (/Users/xxxxx/Documents/Drive/AppDev/firebase/xxxxx/functions/index.js:12:3) at Module._compile (module.js:570:32) at Object.Module._extensions…js (module.js:579:10) at Module.load (module.js:487:32) at tryModuleLoad (module.js:446:12) at Function.Module._load (module.js:438:3) at Module.require (module.js:497:17) at require (internal/module.js:20:19) at /usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:18:11 at Object.<anonymous> (/usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:38:3)

Content of my index.js index.js


const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);

  var config = {
    apiKey: "Alxxxxxxxxxxxxxxxx",
    authDomain: "xxxxxx.firebaseapp.com",
    databaseURL: "https://xxxxx.firebaseio.com"
  };


  firebase.initializeApp(config);

 exports.queryDb = functions.https.onRequest((req,res) =>
 {
   const text = req.query.text;

   console.log('Value of the text >' + text);
   res.send("Return value " + text  );
 });

The error is at this line firebase.initializeApp(config); If I comment that line , then the func deploys fine. I saw a similar thread, but whatever was listed there did not fix my problem. Any pointers would be much appreciated. I am on a mac.

Note: I xxxxx’d out the project and user details in the description above.

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (2 by maintainers)

Most upvoted comments

Hi, you should take another look at the quick start guides for the Firestore and Firebase Functions, they are really great. The error message is clear, you’re calling firebase.initializeApp, but you’ve required firebase-admin as admin. What’s more, you’re actually initializing the admin SDK immediately after requiring it, you don’t have to do it twice.

It’s just a problem with your code, not this package.

Please close the issue and if you will come across some other problems, it’s better to ask such questions on StackOverflow. GitHub is meant to track issues within the packages themselve.

@chezdrz I’m running into this error. How did you solve this?

i face same problem here how can i solved ?please help

`✖ 2 problems (0 errors, 2 warnings)

✔ functions: Finished running predeploy script. i functions: ensuring necessary APIs are enabled… ✔ functions: all necessary APIs are enabled i functions: preparing functions directory for uploading…

Error: Error occurred while parsing your function triggers.`

Does this have anything to do with the Database Rules you setup in your Firebase Project setting ?