0
votes

Hi there I am trying to set up breakpoints in VSCode and use the Chrome debugger. My repo has a Node JS server that runs on http://localhost.lmig.com:3000/.

The main npm command that I need to run is npm start.

My node version is 6.10.0. My local os is Mac OSX and I use zsh with NVM. So far my launch.json is this:

configurations": [
    {
        "type": "chrome",
        "request": "launch",
        "name": "Launch Chrome",
        "url": "http://localhost.lmig.com:3000/",
        "webRoot": "${workspaceFolder}"
    },{
        "type": "node",
        "request": "launch",
        "name": "Launch via NPM",
        "runtimeExecutable": "npm",
        "runtimeVersion": "6.10.0",
        "runtimeArgs": [
            "run-script",
            "start",
            "--debugger=3000"
        ],
        "port": 3000,
        "restart": true,
        "protocol": "legacy",
        "remoteRoot": "0.0.0.0:3000",
        "console": "integratedTerminal",
        "internalConsoleOptions": "neverOpen",
        // "outFiles": ["${workspaceRoot}/build/**/*.js"],
        "sourceMaps": true

    }

My package.json is this:

enter image description here

It runs the node process in the integrated terminal but still doesn't seem to hit my breakpoints.

Please help

1
--debugger=3000 on the same port as what you're hosting your program on doesn't seem right....but I'm not familiar with that option - Cody G

1 Answers

0
votes

Just providing this as an alternative launch config, but it is what I use. You may need to change your "protocol" back to legacy... since you're on an older version of node.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Debug",
            "type": "node",
            "request": "launch",
            "restart": true,
            "program": "${workspaceRoot}/bin/www",
            "stopOnEntry": false,
            "args": [],
            "cwd": "${workspaceRoot}",
            "preLaunchTask": "build",
            "runtimeExecutable": null,
            "runtimeArgs": [
                "--nolazy"
            ],
            "env": {
                "NODE_ENV": "development",
                "PORT": "3000"
            },
            "console": "internalConsole",
            "outputCapture": "std",
            "sourceMaps": true,
            "protocol": "inspector",
            "skipFiles": [
                "${workspaceRoot}/node_modules/**/*.js",
                "${workspaceRoot}/lib/**/*.js",
                "<node_internals>/**/*.js"
            ],
            "internalConsoleOptions": "openOnSessionStart"
        }
    ]
}