我正在尝试从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:UsersrichAppDataLocalTempfbfn_152524dvCL3dZk176index.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:UsersrichAppDataRoamingnpmnode_modulesfirebase-toolslibtriggerParser.js:18:11
at Object.<anonymous> (C:UsersrichAppDataRoamingnpmnode_modulesfirebase-toolslibtriggerParser.js:32:3)
NPM版本5.4.1节点版6.11.0
找到了问题,它是文档中的错字。
应该是:
exports.helloWorld = functions.https.onRequest((request, response) => {
response.send("Hello from Firebase!");
})
即。
函数。 https .onrequest
而不是
函数。 https() .onrequest