Debugging Node.js applications with Visual Studio Code

To enable faster debugging in Visual Studio Code, add the outFiles attribute to the launch.json

        {
            "name": "Node - My App",
            "command": "npm run start:dev",
            "request": "launch",
            "type": "node-terminal",
            "cwd":  "/ABSOLUTE_PATH_TO_MY/APP_FOLDER",
            "outFiles": [
                "${cwd}/build/**/*.js",
                // To step into node modules,
                // "!**/node_modules/**" 
            ]
        },

Add “sourceMap”: true to the tsconfig.json file to create source map files for emitted JavaScript files.

{
  "compilerOptions": {
...
    "sourceMap": true,
...
  }
}

Leave a comment

Your email address will not be published. Required fields are marked *