VS Code debug with --experimental-modules flag

Viewed 2338

I can run my node.js application with es6 modules with the --experimental-modules flag as follows:

node --experimental-modules ./bin/www

How can I do the same when debuggging the application from VS Code, which uses the launch.json configuration file?

{
    "version": "0.2.0",
    "configurations": [
        {
          "type": "node",
          "request": "launch",
          "name": "Launch Program",
          "program": "${workspaceFolder}\\bin\\www",
        }
    ]
}
2 Answers

Instead of using the "program" key you can pass the needed flag in "args" before you pass it your module.

node --experimental-modules ./myModule
{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "run module",
      "type": "node",
      "request": "launch",
      "args": ["--experimental-modules", "${workspaceFolder}/myModule"]
    }
  ]
}

I only learned this last week trying to do the same thing with a Python program.

Related