Reputation: 321
I'm trying to deploy the very first cloud function. It works perfectly fine, but when I try to deploy it in terminal, it sets out warning saying that "functions is declared but it's value is never read".
Is this some common starting mistake, as I am new to this subject? Thank you.
I tried both imports , deploy erros remains same
// const functions = require('firebase-functions');
import * as functions from 'firebase-functions'
Upvotes: 3
Views: 3464
Reputation: 1902
Probably solved, but for me I was expecting ~/functions/index.ts to be the file building but the firebase cli added ~/functions/src/index.ts and THAT was the file.
Upvotes: 0
Reputation: 598797
Your code doesn't declare any Cloud Functions yet, so eslint
warns you that you're importing functions
but not using it.
The message will disappear when you declare a Cloud Function in your index.js
/index.ts
. For example, the documentation on getting started contains this example:
exports.addMessage = functions.https.onRequest((req, res) => { const original = req.query.text; return admin.database().ref('/messages').push({original: original}).then((snapshot) => { return res.redirect(303, snapshot.ref.toString()); }); });
As you can see, this code uses functions
in its first line. So if you add this (or any other Cloud Functions declaration) to your code, you're using functions
and eslint
will no longer warn you about it not being used.
Upvotes: 2
Reputation: 671
The error will disappear when you finally use "functions" in a cloud function.
nevermind, you are better off using const functions = require('firebase-functions');
when importing firebase-functions in your index.js
======== EDIT : ======
Make sure that you have correctly installed those dependencies, by running those npm commands in the right folder:
npm install firebase-functions@latest firebase-admin@latest --save
npm install -g firebase-tools
Upvotes: 0