angular - VSCode Angular 5 Chrome 调试器问题 - 匹配空白? - 和霍尔特

标签 angular visual-studio-code vscode-settings vscode-debugger

enter image description here

其中一项更新突然停止工作后。 我目前正在通过 Chrome 开发者工具进行调试。

ng serve works well and the app is running perfectly.

但是,我想再次使用 VSCode 进行调试.. 尝试了导致上述相同问题的几种配置。 2.

{
"version": "0.2.0",
"configurations": [

  {
    "name": "ng serve",
    "type": "chrome",
    "request": "launch",
    "url": "http://localhost:4200/#",
    "webRoot": "${workspaceFolder}",
    "sourceMapPathOverrides": {
      "webpack:/./*": "${webRoot}/*",
      "webpack:/src/*": "${webRoot}/src/*",
      "webpack:/*": "*",
      "webpack:/./~/*": "${webRoot}/node_modules/*"
    }
  },
  {
    "name": "ng test",
    "type": "chrome",
    "request": "launch",
    "url": "http://localhost:9876/debug.html",
    "webRoot": "${workspaceFolder}"
  },
  {
    "name": "ng e2e",
    "type": "node",
    "request": "launch",
    "program": "${workspaceFolder}/node_modules/protractor/bin/protractor",
    "protocol": "inspector",
    "args": ["${workspaceFolder}/protractor.conf.js"]
  }
]

2.

// {
//    // Use IntelliSense to find out which attributes exist for C# debugging
//    // Use hover for the description of the existing attributes
//    // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
//    "version": "0.2.0",
//    "configurations": [  
//        {
//            "name": "Launch Chrome with ng serve",
//            "type": "chrome",
//            "request": "launch",
//            "url": "http://localhost:4200",
//            "webRoot": "${workspaceRoot}",
//            "sourceMapPathOverrides": {
//                "webRoot": "${workspaceRoot}",
//                "webpack:/*": "${workspaceRoot}/*"
//            }
//        },
//        {
//            "type": "chrome",
//            "request": "attach",
//            "name": "Attach to Chrome",
//            "port": 9222,
//            "webRoot": "${workspaceFolder}"
//        }

//     ,]
// }
{
  "version": "0.2.0",
  "configurations": [{
      "name": "Launch Chrome",
      "type": "chrome",
      "request": "launch",
      "url": "http://localhost:4200",
      "webRoot": "${workspaceFolder}",
      "sourceMapPathOverrides": {
        "webRoot": "${workspaceRoot}",
        "webpack:/*": "${workspaceRoot}/*"
      }
    },
    {
      "name": "Attach Chrome",
      "type": "chrome",
      "request": "attach",
      "url": "http://localhost:4200",
      "port": 9222,
      "webRoot": "${workspaceFolder}"
    },
    {
      "name": "Launch Chrome (Test)",
      "type": "chrome",
      "request": "launch",
      "url": "http://localhost:9876/debug.html",
      "webRoot": "${workspaceFolder}"
    },
    {
      "name": "Launch Chrome (E2E)",
      "type": "node",
      "request": "launch",
      "program": "${workspaceFolder}/node_modules/protractor/bin/protractor",
      "protocol": "inspector",
      "args": ["${workspaceFolder}/protractor.conf.js"]
    }
  ]
}

禁用所有扩展,除了 Chrome 调试器 Visual Studio 团队服务

4200端口未被使用

netstat -a -n -o

我应该如何更改launch.json并通过VSCode恢复调试能力?

最佳答案

当端口 9222 开始使用时会发生此问题,因为此端口是 Debug模式的默认端口,因此只需使用另一个任意数字端口作为启动类型,就像我的 launch.json 文件一样

启动.json

{
    // Use IntelliSense to learn about possible 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": "chrome",
        "request": "launch",
        "name": "Launch Chrome",
        "url": "http://localhost:4200",
        "webRoot": "${workspaceFolder}",
        "port": 4040
        },
        {
          "type": "chrome",
          "request": "attach",
          "name": "Attach to Angular",
          "port": 9222,
           "webRoot": "${workspaceFolder}"
        }
    ]
}

until the time of writing this answer this consider a bug and will be fixed in future releases.

快乐编码

关于angular - VSCode Angular 5 Chrome 调试器问题 - 匹配空白? - 和霍尔特,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51279730/

相关文章:

javascript - Google 跟踪代码管理器在我的页面底部创建空按钮

javascript - 来自 jquery 事件的回调函数

c# - 如何在 Visual Studio Code for Unity 函数名称中获取智能感知?

javascript - VSCode 自动完成时出现重复行

visual-studio-code - 如何在 Visual Studio Code 中重新映射默认的 CTRL+f(查找),以便我可以像在 unix/linux 中那样使用 CTRL+f?

visual-studio-code - 如何使用 Rust 程序禁用 VS 代码中的提示行?

javascript - 造型 Angular 垫-根据条件选择

javascript - 如何在 Angular 项目中的tensorflow.js 中上传csv 文件?

javascript - 如何让 vscode 与全局命名空间一起工作?

visual-studio-code - 配置 launch.json、task.json 和 settings.json 以在 VS Code 中使用 git bash 作为默认终端进行调试?