I followed the following steps:
The Firebase CLI (Command Line Interface) requires Node.js and npm, which you can install by following the instructions on https://nodejs.org/
- Installing Node.js also installs npm
Once you have Node.js and npm installed, install the Firebase CLI via npm:
npm install -g firebase-tools
- This installs the globally available firebase command. To update to the latest version, re-run the same command
Initialize your project:
a. Runfirebase login
to log in via the browser and authenticate the firebase tool.b.Go to your Firebase project directory or create the directory
c. Run firebase init functions
- The tool gives you an option to install dependencies with npm. It is safe to decline if you want to manage dependencies in another way.
Select associated firebase project
Select
Y
to install dependencies with npmMove to directory setup firebase functions
Edit
index.js
file with the function you createdRun the
firebase use --add
to add your Firebase projectRun
firebase deploy --only functions
to deploy the function
After all this I get the message in the terminal at deploy was completed but in the Firebase console, when i click on Functions tab there are no functions listed!?
Make sure you're running at least version
3.5.0
offirebase-tools
. To check which version you have, run:If you're running the default setup, you can update
firebase-tools
using:In step 7, you have to uncomment the sample function in there and save the file. Then, in the output of the deploy command, you will be given a url for the created helloWorld function.
For Cloud Functions, it is required to add your function to the special exports object (it is a Node's way of making the function accessible outside of the current file) Make sure to have index.js in your functions directory:
Example of a function:
Then for deployment follow these steps:
And initialised: $ firebase init
For full deployment: $ firebase deploy
A good read with a very useful example: https://codelabs.developers.google.com/codelabs/firebase-cloud-functions/#7
Quick Tip: Make sure you are exporting the function you are trying to deploy in your index.js file. Your firebase project will deploy but Cloud Functions won't be available unless they are exported.
@Learn2Code I had the exact same issue. Ensure that in your index.js file, you export your function before initializing your app.
Now, go ahead and run
firebase deploy
from your project directory.For example:
Had the same situation. The problem was that when I was doing
That filter name:
myFunction
, was not exactly the same as the name of the function I was trying to deploy. Silly mistake but took me a day to realize...