Uzi
Uzi

Reputation: 2634

Proper way to deploy a Cloud Function for Firebase?

Trying to deploy the simplest Cloud Function for Firebase:

const functions = require('firebase-functions');
    exports.helloWorld = functions.https.onRequest((request, response) => {
    response.send("Hello from Firebase!");
})

I've ran firebase init and selected functions.

The Firebase CLI has created a folder named 'functions' with index.js and package.json inside it. the index file contains the above function.

Then I ran firebase deploy --only functions and got a message in my terminal that the function was deployed. According to this page, I should have gotten a link to the function.

Instead, I got a link to my project's console. There is no sign of the function being deployed on the firebase web console functions section.

Any tips would be greatly appreciated!

Upvotes: 0

Views: 1048

Answers (1)

Robert-Jan Huijsman
Robert-Jan Huijsman

Reputation: 1934

That's surprising! Some things you could try:

  • Double-check that your code matches the examples. Are there any mistakes that snuck in while copy-pasting? Your symptoms could indicate that Cloud Functions doesn't see your "helloWorld" as an exported function, for example.
  • Run the command again, to see if the problem persists. During beta it's not unthinkable that there may be some temporary errors that make your deployment fail, possibly in this surprising way.
  • Update your Firebase CLI to the latest version: npm install -g firebase-tools.
  • If none of those help, try contacting the free troubleshooting support. They can dig into your specific project and find out what's up.

Upvotes: 4

Related Questions