angular/angular-cli · error · Error
Could not find any routes to prerender.
Error message
Could not find any routes to prerender.
What it means
getRoutes collects the routes to prerender from builder options (routes, guessFilename, and extracted routes from the build output). If, after merging all sources, the route set is empty, there is nothing to render and the builder throws this error instead of producing an empty prerender output.
Source
Thrown at packages/angular_devkit/build_angular/src/builders/prerender/index.ts:88
indexFile,
outputPath,
serverBundlePath,
zonePackage,
} as RoutesExtractorWorkerData,
recordTiming: false,
});
const extractedRoutes: string[] = await renderWorker
.run({})
.finally(() => void renderWorker.destroy());
for (const route of extractedRoutes) {
routes.add(route);
}
}
if (routes.size === 0) {
throw new Error('Could not find any routes to prerender.');
}
return [...routes];
}
/**
* Schedules the server and browser builds and returns their results if both builds are successful.
*/
async function _scheduleBuilds(
options: PrerenderBuilderOptions,
context: BuilderContext,
): Promise<
BuilderOutput & {
serverResult?: ServerBuilderOutput;
browserResult?: BrowserBuilderOutput;
}
> {
const browserTarget = targetFromTargetString(options.browserTarget);View on GitHub (pinned to bb72145f9a)
Solutions
- Add routes to the prerender target options: `"routes": ["/", "/about"]`.
- Provide a routesFile (one route per line) and verify its path and contents.
- Check that route discovery/extraction in the app is enabled and emits routes in the build output.
- Verify your app's routing actually declares the routes you expect to be discovered.
Example fix
// before (angular.json)
"prerender": { "builder": "@angular-devkit/build-angular:prerender", "options": {} }
// after
"prerender": {
"builder": "@angular-devkit/build-angular:prerender",
"options": { "routes": ["/", "/products"] }
} Defensive patterns
Strategy: validation
Validate before calling
const routes = options.routes?.length ? options.routes
: options.routesFile ? fs.readFileSync(options.routesFile, 'utf-8').split('\n').filter(Boolean)
: [];
if (routes.length === 0) {
throw new Error('Configure prerender "routes" or a non-empty "routesFile".');
} Try / catch
try {
await ngRun('my-app:prerender');
} catch (e) {
if (e.message.includes('Could not find any routes to prerender')) {
console.error('Add "routes" or "routesFile" to prerender options.');
} else throw e;
} Prevention
- Always configure routes or routesFile for the prerender target.
- Validate the routes file is non-empty and correctly formatted before building.
- Keep route discovery output intact when using application-builder extraction.
- Fail fast in CI by checking prerender options exist.
When it happens
Trigger: Running the prerender builder with no `routes` specified, no `routesFile`, and the application build's extraction (AppShell/route discovery) produced no routes; an empty or misformatted routes file yielding zero parsed routes.
Common situations: Forgetting to configure `routes` in angular.json prerender options; a routes file with blank lines/comments only or wrong path; upgrading to application-builder versions where routes must be declared explicitly instead of inferred.
Related errors
- 'handleSSGRoute' was called for a route which rendering mode
- The 'getPrerenderParams' function defined for the '${stripLe
- The builder requires a target.
- Rendering failed with ${numErrors} worker errors.
- A module or bootstrap option must be provided.
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/f8c01f9c412f134e.
Report an issue: GitHub.