Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js OperationError部署gcloud函数发布_Node.js_Gcloud_Google Cloud Pubsub_Google Cloud Stackdriver - Fatal编程技术网

Node.js OperationError部署gcloud函数发布

Node.js OperationError部署gcloud函数发布,node.js,gcloud,google-cloud-pubsub,google-cloud-stackdriver,Node.js,Gcloud,Google Cloud Pubsub,Google Cloud Stackdriver,我正试图通读的介绍。运行示例代码时: 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.j

我正试图通读的介绍。运行示例代码时:

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
stackdriver上的日志显示:

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> 
D 2019-11-18T23:53:41.689Z publish Node.js文件index.js定义的模块需要导出名为publish的函数
E 2019-11-18T23:53:41.761Z云函数CreateFunction us-central1:发布无效的参数云函数CreateFunction us-central1:发布
E 2019-11-18T23:54:15.667Z云函数更新函数us-central1:发布失败

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