Skip to content

Instantly share code, notes, and snippets.

@arjunrao87
Last active May 15, 2018 03:46
Show Gist options
  • Save arjunrao87/954f5be93d89677ccbcf80bb858851bf to your computer and use it in GitHub Desktop.
Save arjunrao87/954f5be93d89677ccbcf80bb858851bf to your computer and use it in GitHub Desktop.
Node Debugging in VSCode

Debugging Express server in VSCode ( As of 5/2018 )

Node + Express + Babel

Setup

  • Using Babel to transpile ES6 -> ES5
  • Add breakpoints in the src/ folder ( NOT the dist/ folder ) 🔥

Folder structure

  • src/ : Contains .js es6 files
  • dist/ : contains .js es5 files ( transpiled )

VSCode/Project setup

package.json

  • Scripts
    "build": "mkdir -p dist/ && babel src/ -d dist --source-maps",
    "debug": "node --nolazy --inspect-brk=9229 dist/index.js"

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "type": "node",
            "request": "launch",
            "name": "Launch via NPM",
            "runtimeExecutable": "npm",
            "runtimeArgs": [
                "run-script",
                "debug"
            ],
            "outFiles": [ "${workspaceFolder}/dist/**/*.js" ],
            "preLaunchTask": "npm: build",
            "sourceMaps": true,
            "port": 9229,
            "smartStep": true,
        },
      ],
}

Node + Express + Babel + Nodemon

TODO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment