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!?
I went through the same issue recently, while performing Actions on Google Node.js Client Library Version 1 Migration Guide. to Node.js Client Library V2 (That I highly recommend) It took me a while to figure out what what was happening. At the I couldn't really figure out what the problem was! So here is what I did and it worked for me:
Make sure you have a backup copy of your cloud functions (
index.js
) and maybe yourpackage.json
(Just in case you don't want to remember what packages you previously had installed - Could be annoying sometimes).Delete the entire functions directory from your project folder.
Re-launch firebase CLI with
firebase init
and choose FunctionsOnce your cloud function have been initialized, CD into the functions folder and Redeploy it using
firebase deploy --only functions
.If everything goes well
Make sure you save the file after uncommenting the default function and then use
I had exactly the same problem and I solved it by making sure the index.js file containing all my functions was saved on the "functions" folder inside the project folder. I am using vs code so I just clicked on file/save as and selected the correct folder.
To clarify one issue - it appears as though your
index.js
file inside thefunctions
folder must export functions created within the same file (similar to what Fran had said).It seems trying to organize your files into subfolders will not work properly with Firebase functions - same rules apply for using
firebase serve
to test locally (must create codeinsidefunctions/index.js
).Hope this helps someone!
Use
firebase projects:list
andfirebase use <project>
to make sure the Firebase CLI's "current project" is set correctly regardless of what folder you're in.Example:
I had this error as well. I had copied a working function running on Google Cloud Functions from a previous project and could not figure out why it would not show up once deployed.
I needed to wrap my function in functions.https.onRequest(), which is not required on normal cloud functions.