expo/expo · error · Error

Input should not be `index`

Error message

Input should not be `index`

What it means

Input validation in `encodeInput`, which maps a route's RSC `input` to a `.txt` flight-data filename during static export. The empty string is the canonical index route (`''` -> `index.txt`), so the literal string `'index'` is rejected to prevent an ambiguous/duplicate filename collision under `_flight/<platform>/`.

Source

Thrown at packages/@expo/cli/src/start/server/metro/createServerComponentsMiddleware.ts:638

}

export const fileURLToFilePath = (fileURL: string) => {
  try {
    return url.fileURLToPath(fileURL);
  } catch (error) {
    if (error instanceof TypeError) {
      throw Error(`Invalid URL: ${fileURL}`, { cause: error });
    }
    throw error;
  }
};

const encodeInput = (input: string) => {
  if (input === '') {
    return 'index.txt';
  }
  if (input === 'index') {
    throw new Error('Input should not be `index`');
  }
  if (input.startsWith('/')) {
    throw new Error('Input should not start with `/`');
  }
  if (input.endsWith('/')) {
    throw new Error('Input should not end with `/`');
  }
  return input + '.txt';
};

function wrapBundle(str: string) {
  // Skip the metro runtime so debugging is a bit easier.
  // Replace the __r() call with an export statement.
  // Use gm to apply to the last require line. This is needed when the bundle has side-effects.
  return str.replace(/^(__r\(.*\);)$/gm, 'module.exports = $1');
}

View on GitHub (pinned to b09195aac2)

Solutions

  1. Update `expo-router` and `@expo/cli` to matching versions (input normalization bugs are fixed in patch releases).
  2. Inspect generated routes/redirects for any that set the index path to the literal `'index'` and change them to `''`.
  3. Clear the export cache (`expo export -c`).
  4. If it reproduces on a default app, report with the route tree and SDK versions.

Example fix

// before — custom route generation emits the literal index token
const input = route.isIndex ? 'index' : route.path;

// after — use the empty string for the index route as encodeInput expects
const input = route.isIndex ? '' : route.path;
Defensive patterns

Strategy: validation

Validate before calling

// Normalize a route input before passing to encodeInput / exportRoutesAsync.
function normalizeRouteInput(input: string): string {
  if (input === 'index') return '';
  return input;
}
// const safe = normalizeRouteInput(route.input);

Type guard

function isValidRouteInput(input: string): boolean {
  return input !== 'index' && !input.startsWith('/') && !input.endsWith('/');
}

Prevention

When it happens

Trigger: Thrown at createServerComponentsMiddleware.ts:637 when `exportRoutesAsync` (line 586) calls `encodeInput(input)` and a `buildConfig` entry's `input` is exactly `'index'`. Reached during `expo export` for statically-rendered RSC routes.

Common situations: An expo-router version that emits `'index'` instead of `''` for the index route (normalization regression); a custom redirect or generated route whose `input` is set to `'index'`; a route-loading plugin that rewrites the input string.

Related errors


AI-assisted analysis of expo/expo@b09195aac2 (2026-08-12). Data as JSON: /api/errors/f257a1485170c8af. Report an issue: GitHub.