Determines the version of the module located at `modulePath`.

@param {?string} modulePath The absolute path to the root directory of the
module being loaded. This may be null if we are loading an internal module
such as http.
331332
function findModuleVersion(modulePath, load) {
  if (modulePath) {
    var pjson = path.join(modulePath, 'package.json');
    if (fs.existsSync(pjson)) {
      return load(pjson).version;
    }
  }
  return process.version;
}
1025204
function requireMaybe(moduleName) {
  try {
    var modulePath = require.resolve(moduleName);
  } catch (e) {
    return null;
  }
  // just let this fall through
  return require(moduleName);
}
585122
function modulePath(module, node_modules) {
  var pkgFile = path.join(node_modules, module, 'package.json');
  if (!fs.existsSync(pkgFile)) {
    return null;
  }
  var data = fs.readFileSync(pkgFile, 'utf8');
  var pkg = JSON.parse(data);
  var fileName = pkg.main || 'index.js';
  var filePath = path.join(node_modules, module, fileName);
  return realRequirPath(filePath);
}
1148532
function(refPath) {
		var require = function(relModuleId) {
			var moduleId = resolveModuleId(relModuleId, refPath),
				module = getModule(moduleId);

			if (!module) {
				throw "Module not loaded";
			}
			else if (module.error) {
				throw "Error loading module";
			}

			if (!module.exports) {
				module.exports = {};
				var moduleDir = moduleId.substring(0, moduleId.lastIndexOf('/')+1),
					injects = module.injects,
					args = [];

				for (var i = 0, n = injects.length; i<n; i++) {
					if (injects[i] == 'require') {
						args.push(createRequireFunc(moduleDir));
					}
					else if (injects[i] == 'exports') {
						args.push(module.exports);
					}
					else if (injects[i] == 'module') {
						args.push(module.module);
					}
				}

				module.factory.apply(null, args);
			}
			return module.exports;
		};

		require.ensure = function(deps, cb) {
			ensureImpl(deps, cb, refPath);
		};

		if (_mainProgram != null) {
			require.main = getModule(_mainProgram).module;
		}

		return require;
	}
678805
protected File findFile(List<String> loadPaths, String moduleName) {
        String fileName = normalizeName(moduleName);
        File file = new File( moduleName );
        if ( file.isAbsolute() ) {
            if ( file.exists() ) {
                return file;
            }
        }
        for (String loadPath : loadPaths) {
            // require('foo');
            file = new File(loadPath, fileName);
            // foo.js is in the require path
            if (file.exists()) break;
        }
        return file;
    }
1199067
public function getModuleByPath($path)
    {
        // Ensure path exists
        $path = realpath($path);
        if (!$path) {
            return null;
        }

        /** @var Module $rootModule */
        $rootModule = null;

        // Find based on loaded modules
        $modules = ModuleLoader::inst()->getManifest()->getModules();
        foreach ($modules as $module) {
            // Check if path is in module
            if (stripos($path, realpath($module->getPath())) !== 0) {
                continue;
            }

            // If this is the root module, keep looking in case there is a more specific module later
            if (empty($module->getRelativePath())) {
                $rootModule = $module;
            } else {
                return $module;
            }
        }

        // Fall back to top level module
        return $rootModule;
    }
610357
async function assurePath (modulePath, resolve) {
  if (resolveCache[modulePath] === false) {
    return false
  } else if (!(modulePath in resolveCache)) {
    if (typeof resolve === 'function') {
      try {
        resolveCache[modulePath] = !!(await resolve(modulePath))
      } catch (e) {
        resolveCache[modulePath] = false
      }
    }
  }

  return resolveCache[modulePath]
}
103367
function getModulePath(module) {
    if (!module || !module.id) return ""

    var parts = module.id.split("/")

    return parts.slice(0, parts.length-1).join("/")
}
890337
function getorigPath(filePath, base) {
    var extName = path.extname(filePath);
    var pt = path.resolve(base, filePath);
    if (!extName) pt += '.js';
    return pt;
}
1185085
function isCandidate(modulePath) {

        // the 'FromPlugin' suffix is used when a project wants to override a plugin module
        if (modulePath === /.*FromPlugin/) {
            modulePath = modulePath.substring(0, modulePath.length - 10);
        }
        modulePath = modulePath.toLowerCase();

        return !!this.serverModules[modulePath];
    }
305038
function moduleExistsAtPath(modPath) {
	for (var i = 0; i < CODE_EXTENSIONS.length; i += 1) {
		var fileName = 'index' + CODE_EXTENSIONS[i];
		var filePath = path.join(modPath, fileName);

		if (fs.existsSync(filePath)) {
			return true;
		}
	}

	return false;
}
538283
def modulePath(self):
        
        base_path = os.path.dirname(self.filepath())
        module_path = self.importPath()

        module_path = os.path.expanduser(os.path.expandvars(module_path))
        if module_path.startswith('.'):
            module_path = os.path.abspath(os.path.join(base_path, module_path))

        return module_path
330518
function findModulePath(moduleName, currentState) {
    const cwd = currentState.get('cwd');

    if (currentState.get('global')) {
        return path.join(cwd, moduleName);
    }

    // Module._nodeModulePaths does not include some places the node module resolver searches, such as
    // the global prefix or other special directories. This is desirable because if a module is missing
    // in the project directory we want to be sure to report it as missing.
    // We can't use require.resolve because it fails if the module doesn't have an entry point.
    const nodeModulesPaths = Module._nodeModulePaths(cwd);
    const possibleModulePaths = nodeModulesPaths.map(x => path.join(x, moduleName));
    const modulePath = possibleModulePaths.find(pathExists.sync);

    // if no existing path was found, return the first tried path anyway
    return modulePath || path.join(cwd, moduleName);
}
567510
function getMockServerPath(rootPath, mockServerPath) {
    let result = mockServerPath || './src';

    if (!path.isAbsolute(result)) {
        result = path.resolve(rootPath, result);
    }

    return result;
}
484341
def getModulePath(project_path,module_name,verbose):
    ''''''
    if not module_name:
        return None
    sys.path.append(project_path)
    try:
        package = pkgutil.get_loader(module_name)
    except ImportError:
        if verbose:
            print("Parent module for "+module_name+" not found.")
        return None
    except:
        if verbose:
            print(module_name+" not loaded for bizarre reasons")
    try:
        if package: 
                if package.get_code(module_name):
                    filename = package.get_code(module_name).co_filename
                    return filename
                elif package.find_spec(module_name).has_location==False:
                    return None #built-in module such as itertools
                else:
                    pass #perhaps filename is in package.find_spec(module_name).origin?
                    pass #a good reference is https://www.python.org/dev/peps/pep-0302/
    except ImportError:
        if verbose:
            print("Code object unavailable for "+module_name)
        return None
    except AttributeError:
        if verbose:
            print(module_name+" is an ExtensionFileLoader object")
        return None
    except:
        if verbose:
            print(module_name+" not loaded for bizarre reasons")
        return None
    else:
        if verbose:
            print ("Module "+module_name+" not found.")
        return None
1300970
function loadModule (actorPath) {
  try {
    let key = path.resolve(actorPath)
    delete require.cache[ key ]
    return require(actorPath)
  } catch (err) {
    log.error(`Error loading actor module at ${actorPath} with ${err.stack}`)
    return undefined
  }
}
850745
public function checkModuleDepends($moduleName, Version $curVersion, Version $newVersion = null)
    {
        $modules = $this->getListAllModules();
        $clean = true;
        $i = 0;

        foreach ($modules as $module)
        {
            $depends = $this->def($module['name'], 'require', false, array());
            if (!is_array($depends))
            {
                $this->errors->add($this->configFile, $this->configFile.' is corrupted.');
                return false;
            }

            if (array_key_exists($moduleName, $depends))
            {
                if (!is_null($newVersion)) //Check for update a module
                {
                    $dependVersion = new Version($depends[$moduleName]);
                    if (!$newVersion->isPartOf($dependVersion))
                    {
                        $clean = false;
                        $this->errors->add("module_depend_$i", "Can not update $moduleName, ".$module['name'].' Depend to version '.$dependVersion->getOriginalVersion().' of '.$moduleName);
                    }
                }
                else //Check for delete a module
                {
                    $clean = false;
                    $this->errors->add("module_depend_$i", "Can not uninstall $moduleName, ".$module['name'].' Depend this module.');
                }
            }
            $i++;
        }

        if (!$clean)
            return true;
        return false;
    }