使用VS代码调试Vue.js应用程序.错误未验证的断点

Dar*_*rem 11 javascript google-chrome npm vue.js visual-studio-code

我有以下问题.我想用VS Code和Chrome调试我的Vue.js项目.所以我按照网站指南上的官方指南,但它不起作用.问题是我总是得到错误:

 unverified breakpoint
Run Code Online (Sandbox Code Playgroud)

我错了什么?

这是我的 vue.config.js

    module.exports = {
    configureWebpack: {
      devtool: 'source-map'
    }
  }
Run Code Online (Sandbox Code Playgroud)

这是我的调试步骤:

    {
    // 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": "vuejs: chrome",
            "url": "http://localhost:8080",
            "webRoot": "${workspaceFolder}/src",
            "breakOnLoad": true,
            "sourceMapPathOverrides": {
                "webpack:/src/*": "${webRoot}/*",
                "webpack:///./*": "${webRoot}/*",
                "webpack:///src/*": "${webRoot}/*",
                "webpack:///*": "*",
                "webpack:///./~/*": "${webRoot}/node_modules/*",
                "meteor://app/*": "${webRoot}/*"
            }
        }
    ]
}
Run Code Online (Sandbox Code Playgroud)

这是我的package.json

    "name": "test-app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
Run Code Online (Sandbox Code Playgroud)

当我尝试时,npm run serve我收到错误消息unverified breakpoint,我的断点永远不会被击中.

我使用vue-cli 3来生成项目.

有人可以帮我吗?

更新

也许路径有问题.因为当我.scripts在VS Code中的调试器控制台中运行时,我会得到这样的路径

(c:\Users\XY\Desktop\Vue\route-app\webpack:\src\main.ts)
Run Code Online (Sandbox Code Playgroud)

但是没有文件夹webpack:.但我不知道他为什么认为有一个文件夹.他在每个文件中都这样做.

而在我的tsconfig.js我已经有了"sourceMap": true.

更新2

当我选中复选框时All Exceptions,VS Code会显示我的应用程序中的所有异常(它们被捕获).但我的断点仍然不起作用.

更新3

我的项目看起来像这样

C:\Users\User\Desktop\Vue\route-app
|
-----.vscode
     |
     -----launch.json
|
-----node_modules
     |
     ----- modules etc.
|
-----public
     |
     ----- index.html
     |
     ----- manifest.json
     |
     ----- favicon.ico
|
-----src
     |
     ----- components
           |
           ----- all my components.vue files
     |
     ----- views
           |
           ----- all my views.vue files (this files are for routing)
     |
     ----- App.vue
     |
     ----- main.ts
     |
     ----- registerServiceWorker.ts
     |
     ----- router.ts
     |
     ----- shims-tsx.d.ts
     |
     ----- shims-vue.d.ts
     |
     ----- store.ts
|
-----.postcssrc.js
|
-----babel.config.js
|
-----package-lock.json
|
-----package.json
|
-----tsconfig.json
|
-----tslint.json
|
-----vue.config.js
Run Code Online (Sandbox Code Playgroud)

小智 7

配置vue.config.js(如果不存在,创建一个)

module.exports = {
    configureWebpack: {
        devtool: 'source-map'
    }
};
Run Code Online (Sandbox Code Playgroud)

配置 babel.config.js

module.exports = {
  "env":{
    "development":{
      "sourceMaps":true,
      "retainLines":true, 
    }
  },
  presets: [
    '@vue/app'
  ]
}
Run Code Online (Sandbox Code Playgroud)

配置 launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "vuejs: chrome",
            "url": "http://localhost:8080",
            "webRoot": "${workspaceFolder}/src",
            "breakOnLoad": true,
            "sourceMapPathOverrides": {
                "webpack:///src/*": "${webRoot}/*",
                "webpack:///./src/*": "${webRoot}/*"
            }
        },
    ]
}
Run Code Online (Sandbox Code Playgroud)

参考上面的配置就可以正常debug.vue.jsfile了(vue-cli3 + vscode)


Sae*_*eed 6

此调试适配器使用的语法与 Chrome 调试适配器不同:删除 url 和路径末尾的 *:

"webpack:///src/": "${webRoot}/"
Run Code Online (Sandbox Code Playgroud)