How to enable debug for node modules?

contactabbas picture contactabbas · Mar 19, 2015 · Viewed 8.9k times · Source

Having started to work on node.js recently, I am trying to use rename package. Successfully installed (npm install rename) package and sample code (residing in file test.js) is pasted below:

console.log('Starting to rename');
var rename = require('rename');
rename('a.js', 'b.js');
console.log('Rename done');

The file a.js resides in the same directory as test.js. The console shows the two debug messages correctly, but the file a.js is not renamed.

How can I enable debug on rename module (or for that matter any node module), so that I can debug it additional log messages?

Note: Other packages like find, mkdirp, etc are working fine.

Answer

rohitishere1 picture rohitishere1 · Mar 19, 2015

You can enable debug by doing a DEBUG=* node app.js or passign env variable DEBUG with wildcard * . It would enable debug for all modules, provided the module you wish to debug is actually using debug. Hardcore way of doing is to make local changes in the module.