我尝试在此处展示Google Cloud Docs中的hello world示例:https://firebase.google.com/docs/functions/get-started
我安装了所需的npm软件包
{
"name": "functions",
"description": "Firebase Functions",
"dependencies": {
"firebase": "^3.1",
"firebase-admin": "^5.2.1",
"firebase-functions": "^0.6.3"
}
}
我的index.js文件是默认文件:
var functions = require('firebase-functions');
exports.helloWorld = functions.https().onRequest((request, response) => {
response.send("Hello from Firebase!");
})
但是当我尝试部署时:
firebase deploy --only functions
我收到以下回复:
=== Deploying to 'takemyhands-dev'...
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...
Error: Error occurred while parsing your function triggers.
TypeError: functions.https is not a function
at Object.<anonymous> (C:\Users\rich\AppData\Local\Temp\fbfn_152524dvCL3dZk176\index.js:6:32)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at C:\Users\rich\AppData\Roaming\npm\node_modules\firebase-tools\lib\triggerParser.js:18:11
at Object.<anonymous> (C:\Users\rich\AppData\Roaming\npm\node_modules\firebase-tools\lib\triggerParser.js:32:3)
npm版本5.4.1 节点版本6.11.0
答案 0 :(得分:0)
发现问题,这是文档中的拼写错误。
应该是:
exports.helloWorld = functions.https.onRequest((request, response) => {
response.send("Hello from Firebase!");
})
即。
功能。 https .onRequest
而不是
功能。的 HTTPS()强> .onRequest