【发布时间】:2018-01-01 05:14:38
【问题描述】:
我是第一次使用 Gcloud。当我运行以下命令时:
gcloud beta functions deploy FirstBot --stage-bucket [BUCKET_NAME] --trigger-http
我在我的 cmd 中收到此错误:
ERROR: (gcloud.beta.functions.deploy) OperationError: code=3, message=Function l
oad error: File index.js or function.js that is expected to define function does
n't exist in the root directory.
我尝试了 2 个 index.js 文件: 这是第一:
/*
HTTP Cloud Function.
@param {Object} req Cloud Function request context.
@param {Object} res Cloud Function response context.
*/
exports.FirstBot = function FirstBot (req, res) {
response = "This is a sample response from your webhook!" //Default response from the webhook to show it's working
res.setHeader('Content-Type', 'application/json'); //Requires application/json MIME type
res.send(JSON.stringify({ "speech": response, "displayText": response
//"speech" is the spoken version of the response, "displayText" is the visual version
}));
};
这是第二个:
/
HTTP Cloud Function.
@param {Object} req Cloud Function request context.
@param {Object} res Cloud Function response context.
*/
exports.helloHttp = function helloHttp (req, res) {
response = "This is a sample response from your webhook!" //Default response from the webhook to show it's working
res.setHeader('Content-Type', 'application/json'); //Requires application/json MIME type
res.send(JSON.stringify({ "speech": response, "displayText": response
//"speech" is the spoken version of the response, "displayText" is the visual version
}));
};
我的项目名称是 FirstBot。 我也创建了一个桶。
我的 FirstBot 文件夹的路径是 C:\FirstBot。 index.js 文件在其中。 我正在关注以下教程:https://api.ai/docs/getting-started/basic-fulfillment-conversation
请帮助..不胜感激!
【问题讨论】:
-
随着调查的继续,您不应该完全改变问题的上下文 - 使一切无效...而是提出一个新问题,最终将原始问题作为上下文引用。
-
你能解决这个问题吗?如果是这样,建议发布您的答案作为更好地帮助社区的解决方案。如果您仍然遇到问题,建议您运行“gcloud components update”以安装最新的 GCloud 并关注deployment guide。
标签: google-cloud-datastore google-cloud-platform gcloud