Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

express debug module not working

Tags:

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?

like image 882
Nizar Blond Avatar asked Sep 30 '14 02:09

Nizar Blond


People also ask

How do I enable debugging in Express?

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.

How do I debug a NPM module?

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.


1 Answers

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.

like image 193
mscdex Avatar answered Sep 21 '22 21:09

mscdex