Steps to Reproduce:
my launch.json
{
// Use IntelliSense to find out which attributes exist for node debugging
// Use hover for the description of the existing attributes
// For further information visit https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Program",
"type": "node2",
"request": "launch",
"program": "${workspaceRoot}/server.js",
"cwd": "${workspaceRoot}"
},
{
"name": "Attach to Process",
"type": "node2",
"request": "attach",
"port": 5858
}
]
}
@mosluce does this problem occur if you use 'node' instead of 'node' as the debug type?
@weinand
I changed the attach setting to
{
"name": "Attach to Process",
"type": "node",
"request": "attach",
"port": 5858
}
It's working now.
thank you for your help.
@mosluce reopening because this should work with 'node2' too.
If you're going to use 'node2' to attach, you need to start with the --inspect flag to make Node use the new debug protocol.
Hopefully that launch config worked with node2. You can use runtimeArgs to include the harmony flag.
launch and attach are working with settings
scripts
"scripts": {
"start": "node index.js",
"debug": "node --harmony_async_await --debug-brk --inspect index.js"
}
launch.json
{
// Use IntelliSense to find out which attributes exist for node debugging
// Use hover for the description of the existing attributes
// For further information visit https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Launch Program",
"type": "node2",
"request": "launch",
"program": "${workspaceRoot}/index.js",
"cwd": "${workspaceRoot}",
"runtimeArgs": [
"--harmony_async_await"
]
},
{
"name": "Attach to Process",
"type": "node2",
"request": "attach",
"port": 9229
}
]
}
thanks for your help
hi, how do i launch node with the --inspect flag in VS Code?
thanks
@radianz if you use 'node2' as the 'type' in a launch config it will automatically set the '--inspect' flag.
I am still getting this error: Ensure Node was launched with --inspect. Cannot connect to runtime process.
my launch configs are:
{
"version": "0.2.0",
"configurations": [
{
"type": "node2",
"request": "attach",
"name": "Attach to Docker",
"address": "localhost",
"port": 9229,
"restart": true,
"localRoot": "${workspaceRoot}"
}
]
}
Did you launch node with --inspect?
yeah launching the node with --inspect flag fixed the existing error for me. thanks.
but now I am getting another issue that the breakpoints I set in the typescript code get automatically disabled (grayed out) though I have configured source maps to false in "tsconfig.json". Would any idea be appreciated?
Hi,
I faced this issue and the following is the scenario:
OS : Windows 7 64 bit.
Tool : Visual Studio Code
Browser: Chrome
In order to resolve this issue, place the following setting in the launch.config file:
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "chrome",
"request": "launch",
"url": "http://local.wepbage.co",//Change to whatever you homepage is
"runtimeArgs": [
"--new-window", //Open in new window
"--user-data-dir=/home/user", //Can be any directory. Makes chrome load in a different directory so that it opens in a new instance.
"--remote-debugging-port=9222" //Open in port 9222 (standard chrome debug port)
],
"webRoot": "${workspaceRoot}/src/", //The directory that contains js, ts and map files
"sourceMaps": true
}
]
}
Ensure that you have sourceMaps set to true in your tsconfig as well.
We need to open the Visual Studio Code in Normal Mode and not the Administrator Mode(Run As Administrator). This would resolve the problem and allow you to debug. And you can use the Angular CLI also, if needed. Please do let me know if you require any further information. Thank you.
Regards,
S.Srivatsan
Most helpful comment
launch and attach are working with settings
thanks for your help