{"record":{"id":"1bb699a435b4a979","repo":"expo/expo","slug":"internal-error-route-not-found-for-filepath","errorCode":null,"errorMessage":"Internal error: Route not found for \"${filePath}\" while collecting static export paths.","messagePattern":"Internal error: Route not found for \"(.+?)\" while collecting static export paths\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@expo/cli/src/export/exportStaticAsync.ts","lineNumber":558,"sourceCode":"        let filePath = baseUrl + leaf;\n\n        if (leaf === '') {\n          filePath =\n            baseUrl === ''\n              ? 'index'\n              : baseUrl.endsWith('/')\n                ? baseUrl + 'index'\n                : baseUrl.slice(0, -1);\n        } else if (\n          // If the path is a collection of group segments leading to an index route, append `/index`.\n          stripGroupSegmentsFromPath(filePath) === ''\n        ) {\n          filePath += '/index';\n        }\n\n        // This should never happen, the type of `string | object` originally comes from React Navigation.\n        if (!route) {\n          throw new Error(\n            `Internal error: Route not found for \"${filePath}\" while collecting static export paths.`\n          );\n        }\n\n        if (includeGroupVariations) {\n          // TODO: Dedupe requests for alias routes.\n          addOptionalGroups(filePath, route);\n        } else {\n          htmlFiles.add({\n            filePath,\n            route,\n          });\n        }\n      } else if (typeof value === 'object' && value?.screens) {\n        // The __root slot has no path.\n        const newPath = value.path ? baseUrl + value.path + '/' : baseUrl;\n        traverseScreens(value.screens, value._route ?? null, newPath);\n      }","sourceCodeStart":540,"sourceCodeEnd":576,"githubUrl":"https://github.com/expo/expo/blob/b09195aac27c9e4a63daaf12dcb6f00b6b2e08ee/packages/@expo/cli/src/export/exportStaticAsync.ts#L540-L576","documentation":"Thrown deep in the static-export path collector when a resolved `filePath` cannot be matched to a `route` node. The comment explicitly says 'This should never happen', so this is a defensive guard against an internal invariant violation in Expo Router's manifest resolution. A plain `Error` is thrown, naming the unresolved `filePath`.","triggerScenarios":"An internal mismatch between the Router manifest's route nodes and the collected file paths — e.g. a group route, alias, or optional-group edge case the path collector did not account for. Triggered by unusual route layouts, deeply nested optional groups, or custom aliases combined with SSG.","commonSituations":"Exotic router configurations (many nested groups, aliases), upgrading Expo Router across versions where manifest shape changed, beta/unstable router features, or generated/typed routes that drift from the file tree.","solutions":["Treat this as a bug: note the `filePath` and your router layout, then check the Expo Router issue tracker / upgrade guide.","Simplify the route tree (flatten groups, remove unused aliases) to find the structure that triggers the mismatch.","Upgrade `expo-router` and `@expo/cli` to the latest patch — this is the kind of guard that gets fixed across releases.","As a workaround, restructure the offending route so its path resolves without optional-group stitching."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await collectStaticExportPaths(...);\n} catch (e) {\n  if (e instanceof Error && /Internal error: Route not found/.test(e.message)) {\n    // surface the filePath; this is an invariant bug — simplify the route tree and report upstream\n  }\n  throw e;\n}","preventionTips":["Keep router layouts simple; avoid deeply nested optional groups and unusual aliases.","Re-run exports after upgrading `expo-router` and `@expo/cli` — invariant fixes land in patches.","If it reproduces, minimise the route tree to find the offending structure and file an issue with `filePath`."],"tags":["export","ssg","router","internal","routes","invariant"],"backgroundTag":null,"analyzedSha":"b09195aac27c9e4a63daaf12dcb6f00b6b2e08ee","analyzedAt":"2026-08-12T15:59:58.304Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}