Error: Cannot connect to runtime; make sure that runtime is in 'legacy' debug mode
Asked Answered
C

2

7

I see the above when trying to debug Node.js script with Visual Studio Code.

My launch.json looks like

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "attach",
            "name": "Attach to Process",
            "protocol": "legacy",
            "processId": "${command:PickProcess}"
        }
    ]
}

No matter I put the line "protocol": "legacy", or not I get exactly the same error as above. My environment System: OSX Node: v8.6.0 VSC: 1.17.2 Also, I run the node script with PM2.

Any suggestion would be hugely appreciated

Carrasco answered 23/10, 2017 at 16:45 Comment(4)
Can you try starting the process with --debug or --debug-brk switch ?Boole
@Boole I've tried >pm2 reload ecosystem.config.js --debug which returned error: unknown option --debug'`Carrasco
Not familiar with PM2 but with nodemon something like this works for me - "start": "nodemon --debug=5001 app.js", you can try using nodemon for the dev environment and see if it works for youBoole
Also, take a look here #29900753Boole
M
7

Node v8.6 does not support "legacy" protocol. You should use the "inspector" protocol.

Midsection answered 25/10, 2017 at 0:28 Comment(2)
How do I switch to the inspector protocol?Bearwood
@Bearwood just change the protocol in launch.json file. "protocol": "legacy", => "protocol": "inspector",Spoil
C
1

I ran above the same issue using the "legacy" protocol while running the Hello World Extension. After searching a bit, I stumbled on this issue, and change my launch.json file to the following as suggested by @weinand:

{
        "name": "Launch Extension",
        "type": "extensionHost", 
        "request": "launch",
        "runtimeExecutable": "${execPath}",
        "args": [ "--extensionDevelopmentPath=${workspaceRoot}" ],
        "outFiles": [ "${workspaceRoot}/out/src/**/*.js" ]
}
  • using node 8.9.1
  • used the latest version of the yeoman generator for the code.
Colorfast answered 8/8, 2018 at 16:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.