-1

I am accessing a module from the node.js 's require cache. But it is returning a circular JSON structure. I want to access the exports property of the module. Please help :

   var moduleDef = require.cache[moduleName];
   console.log(moduleDef)         // Prints fine
   console.log(moduleDef.exports) // returns undefined
Vikas Sharma
  • 67
  • 1
  • 2

1 Answers1

1

Already answered here

JSON.stringify(moduleDef.exports, function( key, value) {
  if(key == 'moduleName') { 
    return value.id;
  } else {
    return value;
  };
})
Community
  • 1
  • 1
zahreelay
  • 1,742
  • 12
  • 18