How to use Node's debug module (Windows)?

As Traveling Tech Guy suggested in the comment, in a Windows command prompt, the proper syntax is:

set DEBUG=* & npm start

Obviously you can replace npm start with whatever command you need to launch your Node.js app. Just be sure to use the set command and don't forget the & between that command and the one launching your Node.js app!


If you are used to powershell, I recommend this setup in your package.json, then you can just run npm start so you don't type all that out every time.

"scripts": {
    "start": "@powershell $env:DEBUG='*,-express:router*' ; node app.js"
},

Install debug package with npm inside the node application

npm install debug

Open a powershell and then

$Env:DEBUG="name_to_call"

node path_to_js_to_execute.js

Inside your pgm

var debug = require('debug')('name_to_call');