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?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
You can use the Node.js
--inspect
option to debug your code in Chrome. Just like this:And open the Chrome:
chrome://inspect
. That's so cool.You can specify in this doc.
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.
Howto :
1) press ctrl+p in vscode and type ">launch", select "open launch.json"
2) after opening "launch.json", just add to configuration section :
or some more generic version :
So you final json should looks something like here:
After these steps you can see your real async method after pressing F11 in debug mode.
Currently you can use async/await in Node.js 7 or latest using --harmony flag, you can configure your vscode debugger (launch.json) in the following way to run and debug async/await Nodejs code.
You must change the program by your startup script file.
I had major performance issues with VS Code debugging a Node project with TypeScript was unusable, so I found that changing the
protocol=='inspector'
and targetinges2017
allowed a fast and reliable debugging experience. Here is the config I used...launch.json
tsconfig.json
until we have VSCode's support on that subject, you can try putting your results into a var like this:
and check the value in results