'How do you attach the VS Code debugger to a running Sveltekit typescript process?

How do you attach the VS Code debugger in a fresh Sveltekit project?

I have created a repository here.

The launch.json file looks like this:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "pwa-node",
            "request": "attach",
            "name": "Attach Program",
            "processId": "${command:PickProcess}"
        }
    ]
}

When I run the project with npm run dev and launch the debugger, it will not break:

enter image description here

I tried to add sourceMap true to preprocess in svelte.config.js:

preprocess: preprocess({
  sourceMap: true
}),

Why does VS Code tell me it's an "Unbound breakpoint", when I hover the breakpoints?

This is frustrating as I have to debug some Sveltekit code, where I need the "request": "attach" option to work 😅

update I tried modifying the dev script to "dev": "NODE_OPTIONS=\"--inspect\" svelte-kit dev", but no help...



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source