import { u as upath } from './upath.mjs';

function getModulePaths(paths) {
  return [].concat(global.__NUXT_PREPATHS__, ...Array.isArray(paths) ? paths : [paths], process.cwd(), global.__NUXT_PATHS__).filter(Boolean);
}
function resolveModule(id, paths) {
  return upath.normalize(require.resolve(id, { paths: getModulePaths(paths) }));
}
function requireModule(id, paths) {
  return require(resolveModule(id, paths));
}
function getNearestPackage(id, paths) {
  while (upath.dirname(id) !== id) {
    try {
      return requireModule(id + "/package.json", paths);
    } catch {
    }
    id = upath.dirname(id);
  }
  return null;
}

export { getNearestPackage as a, getModulePaths as g, requireModule as r };
