I'm on Windows trying to use the debug module https://www.npmjs.org/package/debug
I installed express-generator
var debug = require('debug')('MyApp'); debug('log'); // I don't see this on console
I tried to debug the variable
console.log(debug); // I get function disabled() {}
How to enable it? shouldn't be enabled by default?
To use this module while running the express app, set the DEBUG environment variable to express:* The output generated on running the command is shown below: These logs help in finding any bug in the program and tell which part of the program is creating the problem.
Method 1: yarn linkIn the folder of ~/awesome-router , run yarn link It actually tells yarn , if others want to link me, I am here. In the folder of ~/try-router , run yarn link awesome-router This will create a symlink folder under node_modules/awesome-router that links to your local copy of the source package.
Output from debug functions created by the debug
module are only displayed when you set the appropriate environment variable when starting your script. That is what lets you selectively enable debug output so that it's not an all or nothing method of displaying debug information. This is similar to how node.js core works for showing internal debug information on the console.
So in your example you would need to execute this at your shell prompt: DEBUG=MyApp node foo.js
, where foo.js
is your script containing var debug = require('debug')('MyApp');
.
For Windows you'd need to do set DEBUG=MyApp
on the command line, followed by node foo.js
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With