function resolveModuleToFile(moduleName, parentDir) {
    var file = new File(moduleName),
      i = 0,
      resolvedFile;
    if (file.exists()) {
      return fileExists(file);
    }
    if (moduleName.match(/^[^\.\/]/)) {
      // it's a module named like so ... 'events' , 'net/http'
      //
      for (; i < modulePaths.length; i++) {
        resolvedFile = new File(modulePaths[i] + moduleName);
        if (resolvedFile.exists()) {
          return fileExists(resolvedFile);
        } else {
          // try appending a .js to the end
          resolvedFile = new File(modulePaths[i] + moduleName + '.js');
          if (resolvedFile.exists()) {
            return resolvedFile;
          }
        }
      }
    } else {
      if ((file = new File(parentDir, moduleName)).exists()) {
        return fileExists(file);
      } else if ((file = new File(parentDir, moduleName + '.js')).exists()) {
        // try .js extension
        return file;
      } else if ((file = new File(parentDir, moduleName + '.json')).exists()) {
        // try .json extension
        return file;
      }
    }
    return null;
  }
*******************************************************************
### module name resolution

When resolving module names to file paths, ScriptCraft uses the following rules...

 1. if the module does not begin with './' or '/' then ...

    1.1 Look in the 'scriptcraft/lib' directory. If it's not there then...
    1.2 Look in the 'scriptcraft/modules' directory. If it's not there then 
        Throw an Error.

 2. If the module begins with './' or '/' then ...
    
    2.1 if the module begins with './' then it's treated as a file path. File paths are 
        always relative to the module from which the require() call is being made.

    2.2 If the module begins with '/' then it's treated as an absolute path.

    If the module does not have a '.js' suffix, and a file with the same name and a .js sufix exists, 
    then the file will be loaded.

 3. If the module name resolves to a directory then...
    
    3.1 look for a package.json file in the directory and load the `main` property e.g.
    
    // package.json located in './some-library/'
    {
      "main": './some-lib.js',
      "name": 'some-library'
    }
    
    3.2 if no package.json file exists then look for an index.js file in the directory
*