firebase使用VS Code附加调试器

时间:2018-03-30 02:45:14

标签: firebase visual-studio-code google-cloud-functions

我使用firebase serve --only functions,hosting命令在本地运行模拟器。这很好用。但我想采取进一步措施,并希望在调试器附加的情况下在本地调试我的函数。网址示例:http://localhost:5001/foo-project/us-central1/helloWorld

是否可以这样做?

如何构建launch.json以将调试器附加到我的函数中?

   {
      "type": "node",
      "request": "attach",
      "name": "Attach",
      "port": 9229
    }

1 个答案:

答案 0 :(得分:-1)

像这样设置您的launch.json:

{
  // Use IntelliSense to learn about possible attributes.
  // Hover to view descriptions of existing attributes.
  // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
  "version": "0.2.0",
  "configurations": [
    {
      "type": "node",
      "request": "launch",
      "name": "Launch Program",
      "program": "${workspaceFolder}/functions/index.js",
      "env": { "FIREBASE_CONFIG": "{\"databaseURL\":\"https://XXXXX-2d371.firebaseio.com\",\"storageBucket\":\"XXXXX-2d371.appspot.com\",\"projectId\":\"XXXX-2d371\"}"}
    }
  ]
}

确保将“程序”设置为功能目录的起点。