Firebase部署错误';Route.post()需要回调函数,但得到了一个[object undefined]?

Firebase部署错误';Route.post()需要回调函数,但得到了一个[object undefined]?,firebase,google-cloud-functions,firebase-cli,Firebase,Google Cloud Functions,Firebase Cli,我在终端中部署Firebase时遇到此错误。在中找不到带有Route.post()的任何代码。看起来它是从一个模块调用的 i deploying functions i functions: ensuring necessary APIs are enabled... ✔ functions: all necessary APIs are enabled i functions: preparing functions directory for uploading... Error:

我在终端中部署Firebase时遇到此错误。在中找不到带有
Route.post()
的任何代码。看起来它是从一个模块调用的

i  deploying functions
i  functions: ensuring 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.

Error: Route.post() requires a callback function but got a [object Undefined]
    at Route.(anonymous function) [as post] (/Users/Desktop/castApp/functions/node_modules/express/lib/router/route.js:202:15)
    at Function.app.(anonymous function) [as post] (/Users/Desktop/castApp/functions/node_modules/express/lib/application.js:482:19)
    at Object.<anonymous> (/Users/Desktop/castApp/functions/index.js:12:5)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
i部署函数
i功能:确保启用必要的API。。。
✔  功能:启用所有必要的API
i函数:正在准备要上载的函数目录。。。
错误:分析函数触发器时出错。
错误:Route.post()需要回调函数,但得到了一个[object Undefined]
at Route.(匿名函数)[as post](/Users/Desktop/castApp/functions/node_modules/express/lib/router/Route.js:202:15)
在Function.app.(匿名函数)[as post](/Users/Desktop/castApp/functions/node_modules/express/lib/application.js:482:19)
反对。(/Users/Desktop/castApp/functions/index.js:12:5)
at模块编译(内部/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js(internal/modules/cjs/loader.js:700:10)
在Module.load(内部/modules/cjs/loader.js:599:32)
在tryModuleLoad(内部/modules/cjs/loader.js:538:12)
at Function.Module._load(内部/modules/cjs/loader.js:530:3)
at Module.require(内部/modules/cjs/loader.js:637:17)
根据需要(内部/modules/cjs/helpers.js:22:18)

在我的例子中,当我删除控制器文件中的函数,但没有更新路由器文件index.js中需要该函数作为回调函数的相应位置时,发生了此错误

index.js:

app.post('/new', addNew);

const { addStandupHost } = require('./APIs/candidates');
candidate.js:

// exports.addNew = (request, response) => {
   //    ...
   //     db operation here
   //     ...
   //}

只需删除index.js中相应的代码即可解决此问题。为了避免此错误,我们应该保持函数导出和导入的一致性。

首先,确保您的CLI完全是最新的。如果仍然没有部署,请直接联系Firebase支持。谢谢你抽出时间。CLI(终端和VS都是最新的)。似乎调试问题超出了Firebase支持的范围。。。或者我遗漏了什么?如果部署时出现问题,那么支持人员至少应该知道,这样他们就可以收集信息并查看其他人是否有相同的问题。填表格没什么坏处。谢谢,我会试试的。。。