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.
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.
Additional details . My package.json
{
"name": "functions",
"description": "Cloud Functions for Firebase",
"scripts": {
"lint": "./node_modules/.bin/eslint .",
"serve": "firebase serve --only functions",
"shell": "firebase experimental:functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"dependencies": {
"firebase": "^4.10.1",
"firebase-admin": "~5.8.1",
"firebase-functions": "^0.8.1"
},
"devDependencies": {
"eslint": "^4.12.0",
"eslint-plugin-promise": "^3.6.0"
},
"private": true
}
Does this have anything to do with the Database Rules you setup in your Firebase Project setting ?
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.
Thank you. I went through the quick start guide and resolved this.
hey you guys just need to return null in your then statement like this
let params = {...};
var firestore = admin.firestore();
var dbRef = firestore.collection('your-collection-name');
dbRef
.add(params)
.then((docRef) => {
console.log("doc added with ID ", docRef.id);
return null
})
.catch((err) => {
console.error("Error in adding document ", err);
});
@chezdrz I'm running into this error. How did you solve this?
Me too
what is version of your node.js and npm ?
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.`
add cross-env NODE_ENV=production to the beginning of the deploy script
What is the origin of this problem? because my problem is generated when I use ng deploy with @angular/fire and there I don't know where control the function
I had this problem and It was solved when I switched my local node version from 13.2.0 to 14.13.0
Any solution yet?
There are several reasons why parsing function trigger may fail. I'd recommend running firebase deploy with --debug flag or sharing additional info available on firebase-debug.log to help us pinpoint the issue.
I also got this error message and in my case I had a circular dependency in my code