vscode debug ES6 application

Here's how to get VSCode debugger to work with Babel 6+:

First install dependencies locally:

$ npm install babel-cli --save
$ npm install babel-preset-es2015 --save

Then run babel-node:

$ node_modules/babel-cli/bin/babel-node.js --inspect --presets es2015 -- server.js --inspect

By default, the debugger will listen on port 5858, so make sure the port matches in launch.json for Attach configuration:

{
  "name": "Attach",
  "type": "node",
  "request": "attach",
  "port": 5858
}

Now attach the debugger in VSCode:

  • make sure debug configuration is set to Attach and not Launch
  • run with F5

Nodemon

Although not required, if you also want to use nodemon to pickup code changes without restarting the server, you can do this:

Make sure nodemon is installed:

$ npm install nodemon --save-dev

Run the server

$ node_modules/.bin/nodemon node_modules/babel-cli/bin/babel-node.js --inspect --presets es2015 -- server.js --inspect

Finally, attach the debugger as shown above.


Assuming you have babel-cli installed as a local module in your project the following should work.

launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "node",
            "request": "launch",
            "program": "${workspaceRoot}/node_modules/babel-cli/bin/babel-node.js",
            "stopOnEntry": false,
            "args": [
                "${workspaceRoot}/server.js"
            ],
...