Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Cannot debug mjs modules #167

Closed
ThePlenkov opened this issue Dec 9, 2017 · 8 comments
Closed

Cannot debug mjs modules #167

ThePlenkov opened this issue Dec 9, 2017 · 8 comments

Comments

@ThePlenkov
Copy link

ThePlenkov commented Dec 9, 2017

Hi,

I hope I chose the correct place to create the issue.

I'm trying to debug mjs node file but the breakpoints are just ignored.

Please see attached gif file.
2017-12-09_10-04-31

This is my configuration:

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Test JSDOM",
            "program": "${workspaceFolder}/jsdom.mjs",
            "runtimeArgs": [
                "--experimental-modules"
            ]
        }
    ]
}

Do I do something wrongly or it's just not supported yet?

Thank you!

@ThePlenkov
Copy link
Author

What is interesting. If to put breakpoint into the classic JS module it stops there. And then you can go back.

But in this case you have a different file:
image

In this file you can already set breakpoints.

@roblourens
Copy link
Member

There are two issues with this:

@ThePlenkov
Copy link
Author

@roblourens the problem is that VS Code debugger even doesn't
stop on debugger statement, not only on start.

The workaround now is like this:
I run from terminal
node --inspect --experimental-modules jsdom.mjs

It automatically starts chrome dev tools with my mjs module. (NIM extesnsion do the magic) So finally I develop in VS Code and debug in Chrome.

I find a very valuable feature opportunity to debug mjs directly from VS Code.

@roblourens
Copy link
Member

@roblourens the problem is that VS Code debugger even doesn't
stop on debugger statement, not only on start.

That's because we start Node in a paused state, then attach. Right now it will skip right over the debugger statement before we are able to attach.

Debugging in Chrome devtools should give a similar experience except for microsoft/vscode-node-debug2#157.

I will move this bug to the right repo and keep it open to track the upstream issue in Node.

@roblourens
Copy link
Member

This issue was moved to microsoft/vscode-node-debug2#158

@ericblade
Copy link

Worth noting that the "runtimeArgs" parameter is not documented at the obvious point in the documentation, https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes

I ended up having to find this bug report to figure out that that parameter exists. I'll see if i can figure out where to properly report that, or fix it if the docs are publicly editable.

@roblourens
Copy link
Member

That section doesn't list all attributes for Node debugging, just a few that are common among different debug adapters. There's a more exhaustive list of Node-specific launch config attributes here https://code.visualstudio.com/docs/nodejs/nodejs-debugging

@ericblade
Copy link

ericblade commented Apr 13, 2018

Seems that it might be good to have a list of all of the launch.json attributes in a place marked "launch.json attributes" ;-) But if debug adapters can use whatever they want, then that's difficult i guess.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants