angular/angular-cli · error · SchematicsException
Bootstrap call not found
Error message
Bootstrap call not found
What it means
findBootstrapModulePath parses the project's main entry (src/main.ts) looking for the `platformBrowserDynamic().bootstrapModule(...)` call. If no bootstrap module call can be found in the main file, the schematic cannot locate the root module and throws this SchematicsException.
Source
Thrown at packages/schematics/angular/utility/ng-ast-utils.ts:51
}
if (
bootstrapCallNode !== null &&
bootstrapCallNode.parent !== undefined &&
bootstrapCallNode.parent.kind === ts.SyntaxKind.CallExpression
) {
bootstrapCall = bootstrapCallNode.parent as ts.CallExpression;
break;
}
}
return bootstrapCall;
}
function findBootstrapModulePath(host: Tree, mainPath: string): string {
const bootstrapCall = findBootstrapModuleCall(host, mainPath);
if (!bootstrapCall) {
throw new SchematicsException('Bootstrap call not found');
}
const bootstrapModule = bootstrapCall.arguments[0];
const mainText = host.readText(mainPath);
const source = ts.createSourceFile(mainPath, mainText, ts.ScriptTarget.Latest, true);
const allNodes = getSourceNodes(source);
const bootstrapModuleRelativePath = allNodes
.filter(ts.isImportDeclaration)
.filter((imp) => {
return findNode(imp, ts.SyntaxKind.Identifier, bootstrapModule.getText());
})
.map((imp) => {
const modulePathStringLiteral = imp.moduleSpecifier as ts.StringLiteral;
return modulePathStringLiteral.text;
})[0];
View on GitHub (pinned to bb72145f9a)
Solutions
- If the project is standalone, the schematic/version may not support it — upgrade Angular or apply the change manually.
- Verify angular.json `browser`/`main` builder option points at the real entry file containing bootstrapModule.
- Restore a standard `platformBrowserDynamic().bootstrapModule(AppModule)` structure if you converted the app by hand.
Example fix
// before (main.ts) bootstrapApplication(AppComponent, appConfig); // after (NgModule-style for legacy schematics) platformBrowserDynamic().bootstrapModule(AppModule).catch(err => console.error(err));
Defensive patterns
Strategy: validation
Validate before calling
const main = fs.readFileSync('src/main.ts', 'utf8');
if (!main.includes('bootstrapModule') && !main.includes('bootstrapApplication')) {
throw new Error('main.ts contains no bootstrap call');
} Prevention
- Keep the standard `platformBrowserDynamic().bootstrapModule(AppModule)` (or bootstrapApplication) call in the configured main file.
- Confirm the angular.json builder `main` option points to the actual entry file.
- For standalone apps, verify schematic support before running ng add/generate.
When it happens
Trigger: Running schematics (e.g. `ng add`, `ng g universal`, app-shell) on a project whose main.ts lacks a `bootstrapModule` call — because the app is standalone (bootstrapApplication), the main path in angular.json points to the wrong file, or the bootstrap code was refactored.
Common situations: Standalone (v14+) applications where main.ts uses `bootstrapApplication(AppComponent, ...)` while the schematic expects NgModule bootstrap; custom entry files; renamed bootstrap expression.
Related errors
- Cannot add provider to invalid bootstrapApplication call in
- Could not find bootstrapApplication call in ${mainFilePath}
- Cannot statically analyze bootstrapApplication call in ${boo
- Option "project" is required.
- Project is not defined in this workspace.
AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30).
Data as JSON: /api/errors/0444175eac861ae1.
Report an issue: GitHub.