无法为Firebase部署云功能

时间:2017-04-06 14:36:59

标签: javascript firebase google-cloud-functions firebase-tools

我正在部署功能很好,但后来它停止工作,我不知道为什么。我已恢复为示例代码(from herehere):

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);
    });

但是现在,当我运行firebase deploy --only functions时,我得到了:

=== 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.

有什么问题?

控制台显示相同的错误消息,没有任何解释:

enter image description here

3 个答案:

答案 0 :(得分:2)

Firebase Tools的3.6.0版本刚刚发布......安装该版本后,部署工作正常!

答案 1 :(得分:0)

终端在您的项目中:

npm install
firebase deploy

答案 2 :(得分:0)

通过查看日志来检查实际日志很有帮助

firebase functions:log

具体问题将在那里可见。我有时会遇到像丢失包一样简单的错误