88

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, and execution does not stop on my breakpoint.

Here is my launch.json file:

{
    linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://localhost:4200",
            "sourceMaps": true,
            "webRoot": "${workspaceFolder}"
        }
    ]
}

App Version:

  • Visual Studio Code: 1.25.1
  • Chrome: 67.0.3396.99

Any other suggestions on how I can solve this issue?

0

30 Answers 30

60

I finally found out whats wrong:

When I read the definition of '${workspaceFolder}', it states the following:

the path of the folder opened in VS Code

My mistake:

My path in Windows to my project was as follow: C:\Users\myusername\Documents\VSCode\Source\ProjectName

Through Visual Studio Code, I had the Source folder open, and always needed to do a change directory (cd ProjectName) command in Integrated Terminal to 'ProjectName'. This lead to the .vscode folder and launch.json file being created in the Source folder, and not the ProjectName folder.

The above mistake lead to the fact that the ${workspaceFolder} was pointing to the Source folder, where no Angular components was, instead of pointing to the ProjectName folder.

The Fix:

In Visual Studio Code, open folder: C:\Users\myusername\Documents\VSCode\Source\ProjectName and setup my launch.json in that directory.

6
  • 35
    Im reading this and I dont understand what is the solution;).... How to set ${workspaceFolder}?
    – P.K.
    Commented Aug 19, 2018 at 5:30
  • 9
    In simpler terms, in Visual Studio Code, open the folder that contains package.json. Commented Aug 29, 2018 at 8:15
  • 1
    How do you read the definition of the ${workspaceFolder} ? (In other words, how to verify the value of that variable in VS Code?)
    – Matt
    Commented Nov 26, 2018 at 15:55
  • 4
    I raised it as a separate question, and got the answer. In case someone needs this information as well.
    – Matt
    Commented Nov 26, 2018 at 17:51
  • 2
    For folks who get here via search, and this isn't the answer. You will also get Unverified Breakpoint if the file you're trying to debug has changes that aren't saved. Commented Mar 22, 2019 at 10:24
29

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}/*"
    }
  }]
}
2
  • This worked for me if I start the Chrome debugging session for the first time but if I change the breakpoints they are not hit.
    – Shamshiel
    Commented Jul 19, 2019 at 12:04
  • THANK YOU! I have never had this problem before but all of a sudden I found myself unable to debug a newly generated Angular 8 project. This fixed it. Commented Sep 4, 2019 at 16:39
13

The above answer is probably going to solve a lot of problems but it didn't solve mine. Mine was a much simpler and more annoying problem...

The configuration settings in the launch.json file are case sensitive.

My "webRoot" entry was correctly spelled but I had a capital B in one of the words instead of a lower case b.

For example:

"webRoot": "${workspaceFolder}/My.Folder"

will not match a folder in your workspace with the name:

My.folder

I hope this helps someone out there.

1
  • Mine was even simpler: I had an extra slash after "workspaceFolder" "webRoot": "${workspaceFolder/}"
    – Jake OPJ
    Commented Feb 25, 2019 at 22:16
12

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.

1
  • this work for me, thank you: { "name": "Chrome", "type": "chrome", "request": "launch", "url": "http://localhost:3000", "webRoot": "${workspaceFolder}/src", }
    – tag
    Commented Jul 29, 2019 at 21:33
10

In my case I had to define the sourceMapPathOverrides value like this:

File launch.json (contained in .vscode folder):

{
  // 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:3000",
      "webRoot": "${workspaceFolder}",
      "sourceMaps": true,
      "smartStep": true,
      "internalConsoleOptions": "openOnSessionStart",
      "sourceMapPathOverrides": {
        "webpack:///*": "${webRoot}/project/app/*"
      }
    }
  ]
}

My source is in ${workspaceFolder}/project/app.

1
  • 1
    adding webpack attribute should work but i had to find path by running command: .scripts in Debug Console of VSCODE while app is launched/running
    – AbhishekS
    Commented Aug 28, 2019 at 9:31
5

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

zero/

enter image description here

Then launch.json

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

For me, the unverified breakpoint was caused because the debugger was running when I tried to set the breakpoint. To solve, I simply turned off the debugger, set the breakpoint as normal, the restarted the debugger.

3
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.

1
  • 1
    The last one "npm start" before debugging helped me. Commented Oct 23, 2019 at 7:51
3

I had to delete my .vscode folder and regenerate it . Also the folder was pointing to the wrong path so I had to change it back to my current project folder path. Thank you

2

In our case this error was because of a windows symlink to have the source code folder available on two local drives. Opened the folder with vscode from the original folder now debugging works good.

0
2

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.

1

If you are using code splitting via webpack, your breakpoint won't be "verified" until Chrome loads that module (i.e. typically when you navigate to that part of your application)

1

My problem was that the source mapping was not configured properly. Be sure that your actual TS sources is visible on the Sources tab within Chrome debug extensions and try to place your breakpoints there firstly. Maybe it will help someone.

1

For me my breakpoints were turned off:

enter image description here

1

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!
1

If everything looks set up correctly but break point still not being hit, the change I needed to make was to specify the exact filename that would be served. For example on NodeJS, Express just specifying localhost:3000 would not stop on my breakpoints, but specifying localhost:3000/index.html worked as expected

Full config:

My folder open in VSCode: learningPixi with full folder location (Ubuntu Linux): /home/leigh/node/pixi-tut/learningPixi

My folder structure is:

/home/leigh/node/pixi-tut/learningPixi/.vscode/launch.json /home/leigh/node/pixi-tut/learningPixi/public/index.html /home/leigh/node/pixi-tut/learningPixi/server.js

Contents of my launch.json file:

{  
  "version": "0.2.0",
  "configurations": [
    {
      "type": "chrome",
      "request": "launch",
      "name": "Launch Chrome against localhost",
      "url": "http://localhost:3000/index.html",
      "webRoot": ${workspaceFolder}/public",
      "skipFiles": ["pixi.min.js"]
    }
  ]
}

"skipFiles" was also very useful otherwise debugger steps into every function call

My (very basic) express server config just for debugging JavaScript in static files was:

const express = require('express');
const path = require('path');

const app = express();
app.use(express.static(path.join(__dirname, '/public')));
app.listen(3000, () => console.log('App started on port 3000'));

And as per folder structure above ensure index.html is located in /public folder

If debugging JavaScript from within an HTML file, you may also need to goto settings within VSCode and enable: Allow Breakpoints Everywhere

0
1

In my case I had a main.js file in the project root for running as an electron app. If this main.js file was removed the problem was solved.

0
1

After spending 3 precious hours of my life and going through many of the answers listed above, my problem was as simple as not having the following line in my php.ini:

xdebug.remote_autostart = 1

Before this I had already configured XDebug on my XAMPP, but my breakpoints simply wouldn't get hit. It was just that my debug server was not configured to be started automatically.

Hope this saves someone's day.

1

I came here while using flutter and dart. I don't know but deleting launch.json in .vscode folder solved my issue

1
  • Though this might have caused the desired effect in your case, it's not a solution IMHO. Feel free to disagree. Commented Nov 3, 2021 at 16:29
1

I tried just about all suggested php.ini configurations but none worked. I suggest this question is untagged from typescript as it isn't language specific but has to do with making vscode settings compatible with debugger extension (in my case, xdebug)

Actually, I was getting "unverified breakpoint" for just one particular class rather than entire project. That breakpoint alone dimmed during app execution

I eventually checked xdebug's logs. In there, it had an entry that read "file name length does not match with breakpoint" with some details pointing to the file and line that dims during app run. So I wiped the log clean and restarted WAMP, and everything started working correctly.

My advice is to check logs for the underlying extension for some clues as to what the problem could be

1
  • 1
    I eventually checked xdebug's logs out of a million advices this is what finally helped me identify the problem. Thanks!
    – Max Flex
    Commented Jan 19 at 12:23
0

In my case the problem was that the breakpoint was set on a line where a function was being declared

openDetails(data: Asset) {         <-- The break point was here
    this.datailsOpen = true;
    this.currentAsset = data;
}

Solution: move it to inside the body of the function

openDetails(data: Asset) {         
    this.datailsOpen = true;        <-- Move the break point here
    this.currentAsset = data;
}
0

I was getting this error simply because I didn't have "sourceMaps": true in my debug configuration.

0

npm i fixed it for my part. I sometimes get unverified breakpoints when creating a new folder/file, and that usually does it.

0

The solution for me was to add to the launch.json file the following line: "requireExactSource": false. After this, restart VSC and try if it work.

0

I had open in VS code my-app folder where client folder and server folder was. I had to change in launch.json from this

"webRoot": "${workspaceFolder}"

to this

"webRoot": "${workspaceFolder}\\client"
0

Another answer which I just discovered is related to lazy loaded modules.

If you want to set breakpoints in code that is part of a lazy loaded module and you haven't loaded that module in the browser, VS code won't have access to the source maps to verify the breakpoints!

so only set breakpoints when you have loaded the lazy loaded module you want to debug!

2
  • It's true for my case as well. I set breakpoints in files called after index.js which is my entry js file and they never get hit. But I set breakpoints at functions in index.js first and it definitely stops there, then I set breakpoints for other files, they stop as well and seems like activated after index.js.
    – Yao Li
    Commented Sep 18, 2019 at 18:07
  • as long as you trigger the route that loads the module into the browser with the related breakpoints in vscode it should work
    – Tom
    Commented Oct 3, 2019 at 11:14
0

For people trying to debug another package or SDK, I needed to click Debug my code + packages + SDK

enter image description here

0

I found the debug diagnostics very helpful, they showed me that the reason why some of my breakpoints were unverified, was a naming problem ("vocabularytest" was for some reason interpreted as "vocabularyTest").

I was working with "firefox" as the type in launch.json and only got the diagnostics when I changed the type to "chrome" and then hovered over an unverified breakpoint.

0

I resolved the problem adding line: "sourceMap": true in the file angular.json.

enter image description here

0

I also had this error. In my case, I was sure that the breakpoints should be hiten and it was not the case...

Additionally, when the breakpoint is not hit, for some reason XDebug sets the breakpoint as "Unverified breakpoint" in my PHP project setup. But when opening the right page to hit the breakpoint, the breakpoint was not "Unverified" and it is hit.

Not the answer you're looking for? Browse other questions tagged or ask your own question.