import { createRequire } from 'node:module';
import { d as dirname, n as normalize } from './nuxi.ffb4843d.mjs';

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

export { getNearestPackage as a, getModulePaths as g, tryRequireModule as t };
