Last active
September 22, 2019 09:16
-
-
Save ashleydavis/0f4ccd40a8253e3dd2641e03a5300376 to your computer and use it in GitHub Desktop.
This snippet of code sets up a hook to intercept calls to require in Node.js. Put this code at the entry point of your app. It's a great debugging tool for Node.js and it even works under Electron!
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// Original code here. | |
// | |
// https://stackoverflow.com/a/41674522/25868 | |
// | |
const m = require('module'); | |
const originalLoader = m._load; | |
m._load = function(request, parent, isMain) { | |
console.log(`## ${request} from ${parent.id} at`); | |
console.trace(); | |
return originalLoader(request, parent, isMain); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment