Debugging Yeoman Generators with Visual Studio Code

Recently I was working on a Yeoman generator to easily stub out a Node.js web server locally that can serve HTTPS requests: generator-nodehttps.

I built this using Visual Studio Code and wanted to set it up so I could easily debug the generator while I was building it, setting breakpoints and the like. Always nice to have breakpoints, watches, call stacks and the ability to step through your code when you hit F5, right?

The trick is how you configure the launch.json file within your project in Visual Studio Code to run Yeoman in debug mode. The way you do this is to make sure you tell Node to startup the Yeoman process on your machine, then pass in each argument you want it to call. Here's what I used to make it work:

Now just set a breakpoint & hit F5 for some VSCode debugging goodness.