Search code examples
javascriptnode.jsdebuggingvisual-studio-codevscode-debugger

How to debug any file in node JS without specifying the file name in launch,json


Check this image

I want to debug both workout.js and test.js but vscode is debugging only the workout.js how do I set the file name dynamic. so I can debug any js file with one launch.json config

Like

"program": "${workspaceFolder}/${currentFileName}.js",

Solution

  • Refer to the documentation for details.

    {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "Node js",
                "program": "${file}",
                "request": "launch",
                "skipFiles": ["<node_internals>/**"],
                "type": "node"
            }
        ]
    }