2017-04-06 120 views
3

我正在部署功能,但後來停止工作,我不知道爲什麼。我已經回覆到示例代碼(from herehere):無法爲Firebase部署雲端功能

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

+0

請出示部署命令的輸出,增加--debug命令行參數。 –

+0

帶有--debug的deploy命令的輸出太大了,無法放在這裏......如果您認爲它可能有幫助,我可以將其捕獲並通過電子郵件發送給您。我回顧了這一點,並沒有學到太多東西。 –

+0

@ frank-van-puffelen我看到你添加了一個「google-cloud-functions」標籤。與Firebase函數不完全不同嗎? –

回答

1

版本的火力地堡工具的3.6.0剛剛出來的......在安裝該版本後,部署工作得很好!

0

項目由終端內部:

npm install 
firebase deploy