Per the AWS documentation, I am starting SAM local like this:
$ sam local start-api -d 5858
I have the following in my launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to SAM Local",
"type": "node",
"request": "attach",
"address": "localhost",
"port": 5858,
"localRoot": "${workspaceRoot}",
"remoteRoot": "/var/task"
}
]
}
But when I launch the visual studio debugger it says"cannot connect to runtime make sure that runtime is in 'legacy' debug mode"
It looks as though many people have this issue with Node.js 6 and Visual Studio Code but I can't seem to find an answer... I'm using version 1.18.1 of Visual Studio Code
I have tried adding "protocol": "Legacy" to launch.json config. I've also tried using --debug-port instead of -d. I'm on Windows 10. Not sure if the issue is windows-specific.

When running sam local either through a terminal or visual studio code's terminal, set your break points and select the name of your
launch.jsonin the debug drop down as shown in the documentation.https://github.com/awslabs/aws-sam-local#debugging-applications
After that, launch sam local start-api. Then when you hit an endpoint on the API you should see the terminal state something like:
Once you see that the debugger is listening. Click the play button on the the debugger. I've noticed that this doesn't usually pick up on its own, unless there is an exception I believe.
I'm using version 1.19.1 of visual studio code.
Have you tried using a different port? This is currently my configuration: