简体   繁体   English

为什么在 VSCode 中调试 VueJS 如此不稳定

[英]Why is debugging VueJS so flaky in VSCode

I have been using VSCode for a few months and have not been able to find a way to consistently debug a simple VueJS app.我已经使用 VSCode 几个月了,但一直无法找到一种方法来一致地调试一个简单的 VueJS 应用程序。 The main issue I keep encountering is the Unbound breakpoint whereby the breakpoints I set are unreachable.我一直遇到的主要问题是Unbound breakpoint ,我设置的断点无法访问。

I have tried the many launch.json configs including the ones below with no success:我尝试了许多launch.json配置,包括以下配置,但均未成功:

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

{
    "name": "Attach hm",
    "port": 9229,
    "request": "attach",
    "skipFiles": ["<node_internals>/**"],
    "type": "pwa-node",
    "address": "localhost:8080",
    "localRoot": "${workspaceFolder}/src"
}

A few weeks ago I stumbled on the following config which magically solved my problem and I was happily debugging for days:几周前,我偶然发现了以下配置,它神奇地解决了我的问题,我愉快地调试了好几天:

{
    "type": "chrome",
    "request": "launch",
    "name": "Launch Chrome against localhost",
    "url": "http://localhost:8080",
    "webRoot": "${workspaceFolder}/src",
    "breakOnLoad": true,
    "sourceMaps": true
}

After taking a few days off coding, I came back to VSCode yesterday, there was the 1.47.2 update waiting.休息了几天编码,我昨天回到 VSCode,等待1.47.2更新。 Did that, wrote a few lines of code, tried debugging like i was doing before and boom!做到了,写了几行代码,像我以前一样尝试调试,然后繁荣! the Unbound breakpoint problem from hell returned.来自地狱的Unbound breakpoint问题返回。

Check my commits, no changes to launch.json, no new install, updates whatsoever.检查我的提交,没有更改 launch.json,没有新安装,没有任何更新。

Why on Earth diid this thing stop working???为什么这东西停止工作了???

One thing to note is that I can perfectly debug in VSCode the server portion of my app (a node/express REST server) with no problem at all.需要注意的一点是,我可以在 VSCode 中完美调试我的应用程序的服务器部分(节点/express REST 服务器),完全没有问题。

Very frustrating and I really do not want to go back to debugging using Chrome's DevTools.非常令人沮丧,我真的不想 go 回到使用 Chrome 的 DevTools 进行调试。

Could anyone help?有人可以帮忙吗?

thank you.谢谢你。

I experienced may times similar issues.我可能遇到过类似的问题。
Have you found a solution?你找到解决办法了吗?
My launch.json file is:我的launch.json文件是:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "chrome",
      "request": "launch",
      "name": "vuejs: chrome",
      "url": "http://localhost:3000",
      "webRoot": "${workspaceFolder}/src",
      "breakOnLoad": true,
      "pathMapping": {
        "/_karma_webpack_": "${workspaceFolder}"
      },
      "sourceMapPathOverrides": {
        "webpack:/*": "${webRoot}/*",
        "/./*": "${webRoot}/*",
        "/src/*": "${webRoot}/*",
        "/*": "*",
        "/./~/*": "${webRoot}/node_modules/*"
      }
    }
  ]
}

Most of times it works but I still experience weird behaviors.大多数时候它有效,但我仍然遇到奇怪的行为。 Also you should always start VS Code from within the folder containing the VUE project (outside /src).此外,您应该始终从包含 VUE 项目的文件夹(在 /src 之外)中启动 VS Code。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM