node.jsvisual-studio-codebabel-nodevscode-debugger

vscode with Node 8 - inspect-brk error


I've recently upgraded my vscode and now I get this error when I try to run the service:

D:\herokuworkspace\server/node_modules/.bin/babel-node.CMD --inspect-brk=27776 src\index.js

D:\Program Files\nodejs\node.exe: bad option: --inspect-brk=27776

This is my configuration:

{
            "type": "node",
            "request": "launch",
            "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/babel-node",
            "name": "Launch Program",
            "program": "${workspaceFolder}/src/index.js",
            "cwd": "${workspaceRoot}",
            "internalConsoleOptions": "openOnSessionStart"
        }

Please advise what should I change in the configuration in order to make it work again.


Solution

  • Your title says Node 8, but it looks like you are using an older version of Node that doesn't support the --inspect-brk flag. You can upgrade to a version after Node 7.6, or you can set the old debug args in your launch config like this (added port and runtimeArgs):

    {
        "type": "node",
        "request": "launch",
        "runtimeExecutable": "${workspaceRoot}/node_modules/.bin/babel-node",
        "runtimeArgs": [ "--inspect=1234", "--debug-brk" ],
        "port": 1234,
        "name": "Launch Program",
        "program": "${workspaceFolder}/src/index.js",
        "cwd": "${workspaceRoot}",
        "internalConsoleOptions": "openOnSessionStart"
    }