I am trying to modify require like this
require = function (path) {
    try {
        return module.require(path);
    } catch (err) {
        console.log(path)
    }
}
However, scope of this modification is only in the current module. I want to modify it globally, so every module that is required by this module will also get the same copy of require function.
Basically, I want to catch SyntaxError to know which file has problem. I can't seem to find any other alternative. If I put module.require in try/catch block, I'll be able to get the file name which caused SyntaxError.
 
     
    