“Unverified breakpoint” in Visual Studio Code with Chrome Debugger extension

后端 未结 25 1978
太阳男子
太阳男子 2020-12-13 01:51

I am trying to debug my Typescript code in Visual Studio Code, using the Chrome Debugger extension, but I am getting the \"Unverified breakpoint\" message on my breakpoint,

相关标签:
25条回答
  • 2020-12-13 02:00

    I also encountered the issue after renaming the project folder and it turned out the "webRoot" property was pointing to "${workspaceFolder}/src" instead of "${workspaceFolder}". Maybe this was snug in as part of an update for the "Debugger for Chrome" extension but since I did not receive any update I cannot verify this.

    Updating "webRoot", restarting the ng serve session and starting a new debug session did the trick. Hope this will help someone with a similar scenerio.

    0 讨论(0)
  • 2020-12-13 02:02

    There are many correct answers given. In my case a combination of all those answers helped, and it took me a long time to figure it out. I hope I can save you some headache time with this, so

    let me summarize it step by step with reference to the answers above what helped me:

    1. It is important to start VS code from the right folder (see answers from CodeChimp and monstertjie_za).
      Open a console window and cd to the project folder.
      Example:
      cd myProject
      code .
    2. Make sure you're configuring the files in the right .vscode folder.
      The right .vscode folder is a subdirectory of your project folder.
      Note: if you have already mistakenly opened VS code in a subfolder level too deep, e.g. in the src folder, then you will find a .vscode folder there (as it was in my case), containing configuration files which are useless for debugging.
    3. Set up a debug configuration in the .vscode\launch.json file.
      Make sure that you have specified the right port for your application, in my case port 4200 was doing fine.
      Also make sure that the "webRoot" parameter is configured correctly (see answer from Stig Perez). In my case it was necessary to add a subfolder to it. To find that out what the path specified by the variable $(workspaceFolder) is, check out the question I've asked at StackOverflow regarding how to display VS code variable values.
      Note: If there is no such configuration yet, do the following to add it: Go to the debug extension (i.e. click on the side bar). In the dropdown of your debugger, select “Add Configuration...”, then press the blue “Add Configuration” button. Select “Launch Chrome” as configuration to be added.
      Example configuration (launch.json):

      "configurations": [
              {
                      "type": "chrome",
                      "request": "launch",
                      "name": "Launch Chrome",
                      "url": "http://localhost:4200",
                      "webRoot": "${workspaceFolder}/projectsubfolder"
              }]
      

      Replace projectsubfolder by the subfolder you might have in your project. Note that this is case-sensitive (see answer from Michael Walsh).

    4. Now set the breakpoints in your application.

    5. To launch your application with debugger, open a terminal window inside VS code, type
      cd projectsubfolder
      npm install & ng serve
      This ensures the dependent packages are resolved and downloaded before your application is being compiled. Wait until the compilation is finished.
      Then, click on the green triangle in the VS debugger which will launch a Chrome window with attached debugger.
      Note: You don't need to run npm install every time, just when packages/dependencies have changed. Most of the time, it is sufficient to execute ng serve to re-compile and run your code.

    0 讨论(0)
  • 2020-12-13 02:02
    Unverified breakpoint
    


    I found 3 causes for this problem:

    1. The launch.json configuration URL automatically generated was incorrect. Make sure the port number matches the localhost port on which your web app runs. I changed mine to 3000 to solve the error:
    "configurations": [
        {
          "type": "chrome",
          "request": "launch",
          "name": "Launch Chrome against localhost",
          "url": "http://localhost:3000",
          "webRoot": "${workspaceFolder}"
        }
      ]
    
    1. I needed to set the correct workspace folder.

    2. I needed to start my web app with npm start before debugging.

    0 讨论(0)
  • 2020-12-13 02:03

    The solution is simple:

    1. Click File->Open Folder-> (select folder of ur project - folder that contains package.json)
    2. Open debug-> press play button to create a new Chrome config.
    3. Set a new break point!
    4. Enjoy!
    0 讨论(0)
  • 2020-12-13 02:04

    Another update for @angular/cli 9.1.7 28/05/2020...

    This is now my working configuration for @angular/cli 9.1.7. Removing the sourceMapPathOverrides

        "sourceMapPathOverrides": {
          "*": "${webRoot}/*"
        }
    
    {
      // 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 against localhost",
        "url": "http://localhost:21460",
        "webRoot": "${workspaceFolder}"
      }]
    }
    
    

    My solution to the "Unverified breakpoint" issue.

    Environment

    • Angular CLI 8.1.1
    • Visual Studio Code 1.36.1
    • Debugger for Chrome extension 4.11.6

    The default .vscode/launch.json created in VSC via the "Add configuration" option will look similar to this (I have changed port from 8080 to 4200).

    {
      // 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 against localhost",
        "url": "http://localhost:4200",
        "webRoot": "${workspaceFolder}"
      }]
    }
    

    Adding item below resolves my issue with "Unverified breakpoint".

    "sourceMapPathOverrides": {
          "*": "${webRoot}/*"
        }
    

    Complete and working .vscode/launch.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 against localhost",
        "url": "http://localhost:4200",
        "webRoot": "${workspaceFolder}",
        "sourceMapPathOverrides": {
          "*": "${webRoot}/*"
        }
      }]
    }
    

    There are some additional items that can be added:

     "breakOnLoad": true,
     "sourceMaps": true,
    

    However, I didn't need these in my case to resolve the problem.

    {
      // 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 against localhost",
        "url": "http://localhost:4200",
        "webRoot": "${workspaceFolder}",
        "breakOnLoad": true,
        "sourceMaps": true,
        "sourceMapPathOverrides": {
          "*": "${webRoot}/*"
        }
      }]
    }
    
    0 讨论(0)
  • 2020-12-13 02:04

    I have a folder structure as shown below and I have opened the zero project on VS Code.

    zero/

    Then launch.json

      "configurations": [
            {
                "type": "chrome",
                "request": "launch",
                "name": "Launch Chrome against localhost",
                "url": "http://localhost:4200",
                "webRoot": "${workspaceFolder}/angular"
            }
        ]
    
    0 讨论(0)
提交回复
热议问题