Search code examples
node.jsvisual-studio-codepm2

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


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


Solution

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