VS Code 中的 Node.js TypeScript 调试

标签 node.js debugging typescript visual-studio-code

有人可以提供一个 VS 代码配置示例,让我可以:

  • 启动 Node.js 调试器
  • 编辑任何 TS 文件,查看重新编译的项目和重新启动的调试器?

开箱即用吗? nodemon 可以以某种方式使用吗?谢谢。

最佳答案

是的,你可以使用 nodemon。在您的 launch.json 中,如果您触发智能感知 (ctrl+space),您将看到带有建议启动配置的片段。有一个用于 nodemon 的,如下所示:

{
    "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-when-source-is-edited

关于VS Code 中的 Node.js TypeScript 调试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42091516/

相关文章:

node.js - 运行 npm link 时跳过 npm install

c# - 调试C#GUI

typescript - 匹配 "any"但不匹配数组

reactjs - 奇怪的 TS2322(类型不可分配)错误

javascript - 语法错误: Unexpected token { when trying to run protractor test

javascript - node.js 中的子/辅助线程

javascript express js 传递异步结果

javascript - 表达next()错误

r - 您可以在 R-Studio 中从 Debug模式恢复对象吗?

java - 有没有办法打印JDBC执行的所有SQL语句?