如何使用visual studio代码firebase-database 触发器函数进行调试?我尝试了模拟器,但是当我调用它时出现错误
functions debug myMethod
C:\functions\functions>functions debug createUserChat
ERROR: Error: Function myMethod in location us-central1 in project myProject does not exist
at C:\Users\Dev\AppData\Roaming\npm\node_modules\@google-cloud\functions-emulator\node_modules\grpc\src\client.js:554:15
Run Code Online (Sandbox Code Playgroud)
这段代码我想调试
require('@google-cloud/debug-agent').start({ allowExpressions: true });;
const functions = require('firebase-functions'),
admin = require('firebase-admin'),
logging = require('@google-cloud/logging')();
admin.initializeApp(functions.config().firebase);
exports.myMethod= functions.database.ref('Tasks/{taskID}/taskStatus').onUpdate(event =>{
// do sth.
});
Run Code Online (Sandbox Code Playgroud)
这是我的启动文件
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug Function",
"type": "node",
"request": "attach",
"port": 5858
}
]
}
Run Code Online (Sandbox Code Playgroud) 我已经启动了一个 firebase 云函数项目,想知道如何在 WebStorm IDE 中运行调试?
我读过我可以使用@google-cloud/functions-emulator 归档我的目标。因此我安装了它并遵循了这个文档
运行后functions inspect myFunction
,我得到以下输出。
Warning: You're using Node.js v10.6.0 but the Google Cloud Functions runtime is only available in Node.js 6 and Node.js 8. Therefore, results from running emulated functions may not match production behavior.
Debugger for app listening on port 9229.
Run Code Online (Sandbox Code Playgroud)
我认为调试现在应该可以工作了。在浏览器中打开 myFunction(例如http://localhost:8010/my-project/us-central1/myFunction/)工作正常。
现在我很挣扎。我需要做什么才能将 IDE 连接到调试器或将调试器连接到 IDE?我不知道调试是如何工作的。
预期结果:我想在 WebStorm IDE 中的断点处暂停后,在 Chrome 浏览器中打开该功能。
感谢您提前提供帮助;)