0

我正在尝试调试我的 js 代码在 firebase 函数上运行。我的步骤是:从功能安装

npm install --save @google-cloud/debug-agent

添加了 index.js:

require('@google/cloud-debug').start();

当我试图跑

firebase deploy --only functions

有一个错误:

Error: Error parsing triggers: Cannot find module '@google/cloud-debu
g'

Try running "npm install" in your functions directory before deployin
4

2 回答 2

0

try: ndb firebase serve

debugger breakpoints are hit with stack traces visible, note it's a little slow so give the debugger time to instrument the child processes

Additionally I was able to debug cloud functions in isolation using (caps for removed values):

GCLOUD_PROJECT=THE-FIREBASE-PROJECT node --inspect-brk /path/to/functions-framework --target FUNCTION-NAME --port=5000

where functions-framework simply expands to the full path for the installed functions-framework (global in my case) and the working directory contains the target index.js for functions.

Alternately when or where the FIREBASE_CONFIG is needed try this format adjusted to fit: FIREBASE_CONFIG="{\"databaseURL\":\"https://YOUR-FIREBASE-PROJECT.firebaseio.com\",\"storageBucket\":\"YOUR-FIREBASE-PROJECT.appspot.com\",\"projectId\":\"YOUR-FIREBASE-PROJECT\"}

于 2019-06-22T13:14:11.680 回答
-1

除了index.js应该是:

require('@google-cloud/debug-agent').start();

或更好:

require('@google-cloud/debug-agent').start({ allowExpressions: true });

我们最近重命名了该模块,您所遵循的说明可能已部分过时。您能否向我们指出您一直遵循的说明?

另请注意,目前对调试云功能的支持是实验性的。在某些情况下(取决于函数的流量),您的函数可能会在调试代理有机会初始化/注册之前完成。我们目前正在研究如何解决这个问题。

于 2017-03-16T15:47:48.057 回答