VS Code中的Node.js TypeScript调试 [英] Node.js TypeScript debugging in VS Code
问题描述
有人可以提供VS Code配置示例,让我:
Can someone provide an example of VS Code configuration that would allow me to:
- 启动Node.js调试器
- 编辑任何TS文件,看到重新编译项目并重新启动调试器了吗?
此功能开箱即用吗?可以以某种方式使用 nodemon
吗?谢谢.
Is this supported out of the box? Can nodemon
be used somehow? Thanks.
推荐答案
是的,您可以使用nodemon.在launch.json中,如果触发智能感知(ctrl + space),则会看到带有建议的启动配置的代码段.nodemon有一个看起来像这样的东西:
Yes, you can use nodemon. In your launch.json, if you trigger intellisense (ctrl+space), you will see snippets with suggested launch configs. There's one for nodemon which looks like this:
{
"type": "node",
"request": "launch",
"name": "nodemon",
"runtimeExecutable": "nodemon",
"runtimeArgs": [
"--debug=5858"
],
"program": "${workspaceRoot}/app.js",
"restart": true,
"port": 5858,
"console": "integratedTerminal",
"internalConsoleOptions": "neverOpen"
}
文档对它的工作方式进行了解释: https://在编辑源代码时,code.visualstudio.com/docs/editor/node-debugging#_restaring-debug-sessions-automatically-自动
The docs have an explanation of how it works: https://code.visualstudio.com/docs/editor/node-debugging#_restaring-debug-sessions-automatically-when-source-is-edited
这篇关于VS Code中的Node.js TypeScript调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!