Help us understand the problem. What is going on with this article?

[WSL] VS Code上でChrome DebuggerのブレイクポイントがUnverified breakpointとなりヒットしない

事象

image.png

ブレイクポイントをセットしても、Unverified breakpoint(未検証のブレイクポイント)となり、セットしたポイントでデバッグが止まりません。

TL;DR

この記事では、上記の事象を解消します。

環境

  • WSL Ubuntu 16.04.6 LT

解決手順

launch.json内で、sourceMapPathOverridesでフォルダのマッピングを定義する必要があるようです。(こちらのオプションの詳細については調べていないため掘り下げません。)

launch.json
{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://localhost:3000",
            "webRoot": "${workspaceFolder}",
            "trace": true,
            "sourceMapPathOverrides": {
                "/mnt/c/*": "C:\\*"
            }
        }
    ]
}

上記の例ではCドライブをマッピングしていますが、もしDドライブにWSLをマウントしているのであれば、 "/mnt/d/*": "D:\\*"となります。

参考文献

https://daniellewis.dev/2019/03/24/getting-chrome-debugger-to-work-in-vs-code-with-windows-subsystem-for-linux/

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away