【问题标题】:How to debug client-side in Visual Studio Code?如何在 Visual Studio Code 中调试客户端?
【发布时间】:2017-06-22 11:29:33
【问题描述】:

根据Microsoft Documentation,Visual Studio Code 调试器应该能够调试 typescript 和 javascript。

有问题的是,它们仅提供使用 node 或 python 的服务器端应用程序的示例。 Intellisense 仅建议服务器语言。

是否可以使用 Visual Studio Code 调试器调试客户端打字稿或 javascript 应用程序?

launch.json

{
    // Use IntelliSense to learn about possible Node.js debug attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [

        {
            "type":"node"      <-- what if I'm building a JS / TS app?
            "request": "launch",
            "name": "Launch Program",
            "program": "${file}",
            "outFiles": [
                "${workspaceRoot}/out/**/*.js"
            ]
        }
    ]
}

【问题讨论】:

标签: debugging visual-studio-code


【解决方案1】:

您必须安装一个(或多个)浏览器调试器扩展:ChromeFirefoxiOS WebEdge

然后你可以对 Chrome 使用这样的启动配置:

{
    "type": "chrome",
    "request": "launch",
    "name": "Launch Chrome",
    "url": "http://localhost:8080",
    "webRoot": "${workspaceRoot}"
}

根据您构建的工作流程,您可能需要执行一些额外的步骤才能使源映射正常工作。

【讨论】:

  • 谢谢!太棒了!
  • 在哪里进行这些配置?
  • 是的,没错,但是“url”参数设置为“localhost:8080”意味着必须启动一个中间网络服务器。如何在 Windows 中建立和设置它?有简单的指南吗?
猜你喜欢
  • 1970-01-01
  • 2015-07-11
  • 1970-01-01
  • 2020-07-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-03-31
相关资源
最近更新 更多