Given a module name and a distribution, attempt to resolve the
    actual path to the module.
977686
def resource_filename_mod_dist(module_name, dist):
    

    try:
        return pkg_resources.resource_filename(
            dist.as_requirement(), join(*module_name.split('.')))
    except pkg_resources.DistributionNotFound:
        logger.warning(
            "distribution '%s' not found, falling back to resolution using "
            "module_name '%s'", dist, module_name,
        )
        return pkg_resources.resource_filename(module_name, '')
300304
function resolveBin (moduleName) {
  // Get the directory from the module's package.json path
  const directory = path.dirname(require.resolve(`${moduleName}/package.json`))

  // Get the relative bin path from the module's package.json bin key
  let bin = require(`${moduleName}/package.json`).bin

  // Sometimes the bin file isn't a string but an object
  // This extracts the first bin from that object
  if (typeof bin !== 'string') {
    bin = Object.values(bin)[0]
  }

  return path.join(directory, bin)
}
62454
def _resolve_setup_path(egg_base, install_dir, egg_path):
        
        path_to_setup = egg_base.replace(os.sep, '/').rstrip('/')
        if path_to_setup != os.curdir:
            path_to_setup = '../' * (path_to_setup.count('/') + 1)
        resolved = pkg_resources.normalize_path(
            os.path.join(install_dir, egg_path, path_to_setup)
        )
        if resolved != pkg_resources.normalize_path(os.curdir):
            raise DistutilsOptionError(
                "Can't get a consistent path to setup script from"
                " installation directory", resolved,
                pkg_resources.normalize_path(os.curdir))
        return path_to_setup
234723
function pkgPath(pkg) {
    pkg = pkg.pkg || pkg;
    var pkgPath = npmResolve(pkg, { basedir:opts.basedir, paths:builtins } );
    if (!pkgPath) throw new Error('cannot resolve module ' + pkg);
    return pkgPath;
  }
780568
function resolvePath(path, options, callback) {
        if (!callback) {
            callback = options;
            options = {};
        }
        
        var alreadyRooted = options.alreadyRooted;
        var checkSymlinks = options.checkSymlinks === undefined 
            ? true : options.checkSymlinks;
        var isHome        = false;
        
        if (checkSymlinks === undefined)
            checkSymlinks = true;
        if (path.substr(0, 2) == "~/") {
            isHome = true;
            path = process.env.HOME + path.substr(1);
        }
        else if (!alreadyRooted) 
            path = join(root, path);

        if (checkSymlinks && fsOptions.checkSymlinks && !alreadyRooted) 
            fs.realpath(path, check);
        else check(null, path);

        function check(err, path) {
            if (err) return callback(err);
            
            if (!options.nocheck) {
                if (!(path === base || path.substr(0, root.length) === root)
                  && !isHome) {
                    err = new Error("EACCESS: '" + path + "' not in '" + root + "'");
                    err.code = "EACCESS";
                    return callback(err);
                }
            }
            callback(null, path);
        }
    }
741302
def _get_modpkg_path(dotted_name, pathlist=None):
    
    # split off top-most name
    parts = dotted_name.split('.', 1)

    if len(parts) > 1:
        # we have a dotted path, import top-level package
        try:
            file, pathname, description = imp.find_module(parts[0], pathlist)
            if file: file.close()
        except ImportError:
            return None

        # check if it's indeed a package
        if description[2] == imp.PKG_DIRECTORY:
            # recursively handle the remaining name parts
            pathname = _get_modpkg_path(parts[1], [pathname])
        else:
            pathname = None
    else:
        # plain name
        try:
            file, pathname, description = imp.find_module(
                dotted_name, pathlist)
            if file:
                file.close()
            if description[2] not in [imp.PY_SOURCE, imp.PKG_DIRECTORY]:
                pathname = None
        except ImportError:
            pathname = None

    return pathname
326566
def tryImportModule(self, name):
        
        self._name = name
        try:
            import importlib
            self._module = importlib.import_module(name)
        except ImportError:
            self._module = None
            self._version = ''
            self._packagePath = ''
        else:
            if self._versionAttribute:
                self._version = getattr(self._module, self._versionAttribute, '???')
            if self._pathAttribute:
                self._packagePath = getattr(self._module, self._pathAttribute, '???')
1339217
def find_module(self, fullname, path=None):
        
        # path points to the top-level package path if any
        # and we can only import sub-modules/-packages
        if path is None:
            return
        if fullname.startswith(self.module_prefix):
            return self
        else:
            return None
46242
def module2uri(self, module_name):
        """"""
        assert module_name.startswith(self.module_prefix), 'incompatible module name'
        path = module_name[len(self.module_prefix):]
        path = path.replace('&#DOT', '.')
        return path.replace('&#SEP', os.sep)
1146672
function packageNameFromPath(path) {
  var matches = moduleRegex.exec(path);
  return matches && matches.length > 1 ? matches[1] : null;
}
854870
def load_module(self, name):
        
        if name in sys.modules:
            return sys.modules[name]
        path = self.module2uri(name)
        if os.path.isfile(path):
            return self._load_module(name, path)
        elif os.path.isdir(path):
            return self._load_package(name, path)
        else:
            raise ImportError("Missing module source file %r" % path)
735374
function resolve() {
	var parts,
		flg,
		len,
		str,
		i;

	// CASE 1: this module is loaded from a global path...
	len = gpaths.length;
	for ( i = 0; i < len; i++ ) {
		str = dir.substring( 0, gpaths[ i ].length );
		if ( str === gpaths[ i ] ) {
			// We are loaded from a global path. Resort to finding the nearest `package.json` walking up from the current working directory...
			str = pkgdir();
			if ( str ) {
				return str;
			}
			flg = true;
		}
	}
	// CASE 2: this module is a local module dependency; in which case, split on `node_modules`...
	parts = dir.split( path.sep+'node_modules' );
	if ( parts.length > 1 ) {
		// We are a nested module. Assume that the top-level node module directory is the application root...
		return parts[ 0 ];
	}
	// CASE 3: possibly a git submodule, copy and paste, or some other dependency pattern; in which case, find the nearest `package.json` walking up from the current working directory...
	if ( !flg ) {
		str = pkgdir();
		if ( str ) {
			return str;
		}
	}
	// CASE 4: nothing worked. Just use the main module...
	return path.dirname( require.main.filename );
}
1238524
def find_module(module, paths=None):
    """"""

    parts = module.split('.')

    while parts:
        part = parts.pop(0)
        f, path, (suffix, mode, kind) = info = imp.find_module(part, paths)

        if kind == PKG_DIRECTORY:
            parts = parts or ['__init__']
            paths = [path]

        elif parts:
            raise ImportError("Can't find %r in %s" % (parts, module))

    return info
225147
function resolveModuleDirectoryFrom(src: string, name: string): string {
  return resolveFrom(src, name).replace(
    /node_modules\/([^/]+).*$/,
    'node_modules/$1'
  );
}
372616
def module_to_path(mod, base=nil)
      path = mod.gsub(/\./, ::File::SEPARATOR) + '.py'
      path = ::File.join(base, path) if base
      path
    end
998427
function resolvePath(filepath) {
  filepath = filepath.replace(RE_TRAILING, '');
  const cwd = process.cwd();
  const npmPackage = filepath.includes('node_modules');

  // Find nearest node_modules directory
  if (npmPackage) {
    const parts = filepath.split(path.sep);
    let idx = parts.lastIndexOf('node_modules');

    if (idx < parts.length - 1) idx += 2;
    // Handle scoped
    if (parts[idx - 1].charAt(0) == '@') idx++;

    const dir = parts.slice(0, idx).join(path.sep);

    // Installed packages must have manifest, otherwise continue
    if (exists(path.join(dir, 'package.json'))) return dir;
  }

  // Find nearest directory with node_modules subdirectory
  if (filepath.includes(cwd)) {
    let depth = maxFileSystemDepth;
    let dir = filepath;
    let parent = '';

    while (true) {
      parent = path.dirname(dir);
      // Stop if we hit max file system depth or root
      // Convert to lowercase to fix problems on Windows
      if (!--depth || parent.toLowerCase() === dir.toLowerCase()) {
        break;
      }

      // Stop at nearest directory with node_modules or cwd
      if (dir == cwd || exists(path.resolve(dir, 'node_modules'))) return dir;

      // Walk
      dir = parent;
    }
  }

  // Return project directory if file isn't a project file
  return cwd;
}
888097
function (moduleName, depName) {
            var i = 0, l;

            if (!depName) {
                return depName;
            }

            if (typeof depName === 'string') {
                if (startsWith(depName, '../') || startsWith(depName, './')) {
                    // x/y/z -> x/y/
                    return Path.resolve(Path.dirname(moduleName), depName);
                }

                return Path.normalize(depName);
            }

            for (l = depName.length; i < l; i++) {
                depName[i] = Utils.normalDepModuleName(moduleName, depName[i]);
            }
            return depName;
        }