function registerMod(leaf, dir, name) {
  var modPath;
  try {
    modPath = require.resolve(dir);
  } catch (_error) {}
  if (modPath == null) {
    return false;
  }
  // Define a getter with the base name.
  name = path.basename(name, path.extname(name));
  Object.defineProperty(leaf, name, {
    configurable: true,
    enumerable: true,
    get: function () {
      if (require.cache[modPath] == null) {
        debug('loading %s.', modPath);
      }
      return require(modPath);
    }
  });
  return true;
}
function registerMod(leaf, dir, name) {
  var modPath;
  try {
    modPath = require.resolve(dir);
  } catch (_error) {}
  if (modPath == null) {
    return false;
  }
  
  name = path.basename(name, path.extname(name));
  Object.defineProperty(leaf, name, {
    configurable: true,
    enumerable: true,
    get: function () {
      if (require.cache[modPath] == null) {
        debug('loading %s.', modPath);
      }
      return require(modPath);
    }
  });
  return true;
}
function registerMod ( leaf , dir , name ) { var modPath ; try { modPath = require . resolve ( dir ) ; } catch ( _error ) { } if ( modPath == null ) { return false ; } // Define a getter with the base name. name = path . basename ( name , path . extname ( name ) ) ; Object . defineProperty ( leaf , name , { configurable : true , enumerable : true , get : function ( ) { if ( require . cache [ modPath ] == null ) { debug ( 'loading %s.' , modPath ) ; } return require ( modPath ) ; } } ) ; return true ; }
Try to handle with require().
Try to handle with require () .