4

I was deploying functions just fine, but then it stopped working, and I don't know why. I've reverted back to the sample code (from here or here):

const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp(functions.config().firebase);

// Listens for new messages added to /messages/:pushId/original and creates an
// uppercase version of the message to /messages/:pushId/uppercase
exports.makeUppercase = functions.database.ref('/messages/{pushId}/original')
    .onWrite(event => {
      // Grab the current value of what was written to the Realtime Database.
      const original = event.data.val();
      console.log('Uppercasing', event.params.pushId, original);
      const uppercase = original.toUpperCase();
      // You must return a Promise when performing asynchronous tasks inside a Functions such as
      // writing to the Firebase Realtime Database.
      // Setting an "uppercase" sibling in the Realtime Database returns a Promise.
      return event.data.ref.parent.child('uppercase').set(uppercase);
    });

But now, when I run firebase deploy --only functions I get:

=== Deploying to 'mydb'...

i  deploying functions
i  functions: ensuring necessary APIs are enabled...
i  runtimeconfig: ensuring necessary APIs are enabled...
+  runtimeconfig: all necessary APIs are enabled
+  functions: all necessary APIs are enabled
i  functions: preparing functions directory for uploading...
i  functions: packaged functions (2.04 KB) for uploading
!  functions: Upload Error: Cannot read property 'response' of undefined
i  starting release process (may take several minutes)...
i  functions: updating function makeUppercase...
!  functions[makeUppercase]: Deploy Error: Function load error: Node.js module defined by file index.js is expected to export function named makeUppercase
+  functions: 0 function(s) deployed successfully.


Functions deploy had errors. To continue deploying other features (such as database), run:
    firebase deploy --except functions

Error: Functions did not deploy properly.

What is wrong?

The console shows the same error messages, without any more explanations:

enter image description here

AL.
  • 36,815
  • 10
  • 142
  • 281
Glen Little
  • 6,951
  • 4
  • 46
  • 68
  • Please show the output of the deploy command, adding --debug to the command line arguments. – Doug Stevenson Apr 06 '17 at 19:50
  • The output of the deploy command with --debug is way too big to put here... I could capture it and email it to you, if you think it might help. I reviewed that and didn't learn much. – Glen Little Apr 06 '17 at 23:17
  • @frank-van-puffelen I see you added a "google-cloud-functions" tag. Isn't that quite different than Firebase Functions? – Glen Little Apr 06 '17 at 23:19
  • 1
    Cloud Functions for Firebase *is* Google Cloud Functions, but with additions that integrate Firebase features. And you could send your log to a service like pastebin and link to it here. – Doug Stevenson Apr 07 '17 at 00:10
  • 1
    See [What is the difference between Cloud Function and Firebase Functions? ](http://stackoverflow.com/questions/42854865/what-is-the-difference-between-cloud-function-and-firebase-functions). – Frank van Puffelen Apr 07 '17 at 00:42
  • i'm having this problem with version 3.9.0 – MikeG May 23 '17 at 04:17

3 Answers3

2

Version 3.6.0 of the Firebase Tools just came out... after installing that version, the deploy worked fine!

Glen Little
  • 6,951
  • 4
  • 46
  • 68
0

Inside your project by the terminal:

npm install
firebase deploy
Oscar Duarte
  • 521
  • 5
  • 5
0

It's much helpful to examine the actual logs by viewing the log

firebase functions:log

The specific issue will be visible there. I sometimes had error as simple as a missing package

Abraham
  • 12,140
  • 4
  • 56
  • 92