部署gcloud函数的OperationError发布

时间:2019-11-19 00:27:09

标签: node.js gcloud google-cloud-pubsub google-cloud-stackdriver

我正在尝试浏览Google Cloud Pub/Sub Triggers的简介。运行示例代码时:

gcloud functions deploy publish --runtime nodejs8 --trigger-http

我收到以下错误:

ERROR: (gcloud.functions.deploy) OperationError: code=3, message=Function failed on loading user code. Error message: Node.js module defined by file index.js is expected to export function named publish

堆栈驱动程序上的日志显示:

D 2019-11-18T23:53:41.689Z publish Node.js module defined by file index.js is expected to export function named publish  
E 2019-11-18T23:53:41.761Z Cloud Functions CreateFunction us-central1:publish <email> INVALID_ARGUMENT Cloud Functions CreateFunction us-central1:publish <email> 
E 2019-11-18T23:54:15.667Z Cloud Functions UpdateFunction us-central1:publish <email> FAILED_PRECONDITION Cloud Functions UpdateFunction us-central1:publish <email> 

1 个答案:

答案 0 :(得分:1)

结果是我试图从错误的目录进行部署。正确的index.js文件包含函数定义,并允许该函数成功部署。