```ts
/** An installation order for packages under prerequisite pairs. */
export function installOrder(
  packages: string[],
  requires: string[][],
): string[] {
  const needs: Record<string, number> = {};
  const enables: Record<string, string[]> = {};
  for (const name of packages) {
    if (packages.indexOf(name) !== packages.lastIndexOf(name)) {
      throw new Error(`Duplicate package name: ${name}`);
    }
    needs[name] = 0;
    enables[name] = [];
  }

  for (const [pkg, needed] of requires) {
    if (!packages.includes(pkg)) {
      throw new Error(`Package not found in list: ${pkg}`);
    }
    if (!packages.includes(needed)) {
      throw new Error(`Package not found in list: ${needed}`);
    }
    needs[pkg] += 1;
    enables[needed].push(pkg);
  }

  const ready = packages.filter((name) => needs[name] === 0).sort();
  const order: string[] = [];
  while (ready.length > 0) {
    const next = ready.shift() as string;
    order.push(next);
    for (const follower of enables[next]) {
      needs[follower] -= 1;
      if (needs[follower] === 0) {
        ready.push(follower);
      }
    }
  }

  if (order.length !== packages.length) {
    throw new Error('Cycle detected in requirements');
  }

  return order;
}
```