如何在Visual Studio代码中调试异步/等待? [英] How to debug async/await in visual studio code?
问题描述
我想在Visual Studio代码中调试包含async/await的js文件,但它提醒我vscode不支持它.如何使vscode支持异步/等待?
I want to debug js file that includes async/await in visual studio code,but it reminds me that vscode doesn't support it. What can I do to make vscode support async/await?
推荐答案
到目前为止,在2019年,最新的VSCode支持异步/等待调试,只是想共享解决方案以防止vscode进入"(通过f11)进入在调试nodejs应用程序期间通过" async_hooks.js "和" inspector_async_hook.js "文件实现async/await方法.
As now, in 2019, latest VSCode supporting async/await debug, just would like to share solution to prevent vscode to "Step into" (by f11) into async/await method through the "async_hooks.js" and "inspector_async_hook.js" files during debug nodejs applications.
方法:
1)在vscode中按ctrl + p并输入> launch",选择打开launch.json"
1) press ctrl+p in vscode and type ">launch", select "open launch.json"
2)打开"launch.json"后,只需将其添加到配置部分:
2) after opening "launch.json", just add to configuration section :
"skipFiles": [
"inspector_async_hook.js",
"async_hooks.js"
]
或更通用的版本:
"skipFiles": ["<node_internals>/**"]
所以最终的json应该看起来像这里:
So you final json should looks something like here:
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceFolder}\\index.js",
"skipFiles": ["<node_internals>/**"]
}
]
}
在这些步骤之后,您可以在调试模式下按F11键后看到真正的异步方法.
After these steps you can see your real async method after pressing F11 in debug mode.
这篇关于如何在Visual Studio代码中调试异步/等待?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!