3

I am trying to debug my angular code from visual studio cod. Have installed the plugin Debugger for chrome and added all the configuration required in Google Chrome for attaching debugger to a process.

Below is the configuration in launch.json file.

 "version": "0.2.0",
"configurations": [
    {
        "type": "chrome",
        "request": "attach",
        "name": "Attach to Chrome",
        "port": 9222,
        "url":"http://localhost:4200*",
        "webRoot": "${workspaceFolder}"
    },
    {
        "type": "node",
        "request": "launch",
        "name": "Launch Program",
        "program": "${workspaceFolder}\\serve"
    }
]

After attaching it to the chrome process the breakpoints are not hit. The control goes to a read only file served from inline content in source map. Attaching the snapshot below.

enter image description here

Please let me know if I am missing something. I really need to get this working.

2 Answers 2

2

How are you building and serving your code? This message usually means that VS Code can't find your source files where the source maps are telling it to look.

Based on the configuration you provide, I would suggest checking the value of webRoot. It should be the directory where your built files actually are. So, if your code compiles to a build folder, say, then your webRoot should be "${workspaceFolder}/build".

For example, if I have a workspace that looks like this:

src/
  test.ts
build/
  index.html
  test.js
  test.js.map

Then the following launch.json configuration works for me:

{
  "version": "0.2.0",
  "configurations": [
    {
      "type": "chrome",
      "request": "launch",
      "name": "Launch Chrome against localhost",
      "url": "http://localhost:8080",
      "webRoot": "${workspaceFolder}/build",
      "sourceMaps": true
    }
  ]
}
Sign up to request clarification or add additional context in comments.

Comments

2

I've also been wrestling with this, and got it working thanks to this Github issue:

https://github.com/angular/angular-cli/issues/2453

Actually my situation didn't concern an Angular app but a Vue.js app launched through Laravel Mix, which I tried to debug using VSCode.

My launch.json which finally worked:

{ "version": "0.2.0", "configurations": [ { "type": "chrome", "request": "launch", "name": "vuejs: chrome", "url": "http://localhost:8080", "sourceMaps": true, "webRoot": "${workspaceFolder}/resources/assets/js", "breakOnLoad": true, "sourceMapPathOverrides": { "webpack:///./*": "${webRoot}/*" } } ] }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.