如何使用 firebase:shell 附加调试器 - firestore 云函数

sat*_*mar 2 firebase google-cloud-functions firebase-cli

在本地成功配置firestore云功能。

能够使用以下命令在本地运行这些功能。

  1. firebase 功能:shell --port=3535

firebase var data = require('./data'); wChangedEvent(data.default);

... ... 打印 wChangedEvent 中的 console.log。所以这是正常工作的。

但我需要在 Visual Studio 代码中附加调试器。我尝试使用以下配置。

   {
        "type": "node",
        "request": "attach",
        "name": "Attach",
        "port": 3535,
        "protocol": "inspector"
    },
Run Code Online (Sandbox Code Playgroud)

但它不起作用。

geg*_*geg 5

截至 2020 年底,此拉取请求增加了对该--inspect-functions标志的支持。

firebase functions:shell --inspect-functions
Run Code Online (Sandbox Code Playgroud)

除非您明确提供另一个端口,否则它将打开默认的节点调试器端口9229

使用 Jetbrains IDE,您可以使用“附加到 Node.js/Chrome”运行配置来附加到正在运行的进程。