{"record":{"id":"be8dfe2ee7d3733d","repo":"angular/angular-cli","slug":"could-not-find-bootstrapapplication-call-in-main","errorCode":null,"errorMessage":"Could not find bootstrapApplication call in ${mainFilePath}","messagePattern":"Could not find bootstrapApplication call in (.+?)","errorType":"exception","errorClass":"SchematicsException","httpStatus":null,"severity":"error","filePath":"packages/schematics/angular/utility/standalone/util.ts","lineNumber":89,"sourceCode":"      if (\n        ts.isCallExpression(node) &&\n        ts.isIdentifier(node.expression) &&\n        node.expression.text === localName\n      ) {\n        result = node;\n      }\n\n      if (!result) {\n        node.forEachChild(walk);\n      }\n    });\n\n    if (result) {\n      return result;\n    }\n  }\n\n  throw new SchematicsException(`Could not find bootstrapApplication call in ${mainFilePath}`);\n}\n\n/**\n * Finds the local name of an imported symbol. Could be the symbol name itself or its alias.\n * @param sourceFile File within which to search for the import.\n * @param name Actual name of the import, not its local alias.\n * @param moduleName Name of the module from which the symbol is imported.\n */\nfunction findImportLocalName(\n  sourceFile: ts.SourceFile,\n  name: string,\n  moduleName: string,\n): string | null {\n  for (const node of sourceFile.statements) {\n    // Only look for top-level imports.\n    if (\n      !ts.isImportDeclaration(node) ||\n      !ts.isStringLiteral(node.moduleSpecifier) ||","sourceCodeStart":71,"sourceCodeEnd":107,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/schematics/angular/utility/standalone/util.ts#L71-L107","documentation":"findBootstrapApplicationCall traverses the main entry file's AST looking for a call to bootstrapApplication (accounting for imports/aliases). If no such call exists anywhere in the file, it throws this SchematicsException with the inspected file path.","triggerScenarios":"Running standalone-oriented schematics (`ng add` of libraries, provider insertion, isStandaloneApp checks) against a main.ts that still bootstraps via NgModule (platformBrowserDynamic().bootstrapModule), or a wrong/renamed entry file configured in angular.json.","commonSituations":"Mixed or partially migrated apps; pointing schematics at a polyfill or secondary entry point instead of the real main; apps bootstrapped with a custom framework wrapper.","solutions":["Ensure the file configured as the project's main/browser entry contains a `bootstrapApplication` call.","For NgModule apps, migrate to standalone (`ng generate @angular/core:standalone` migration) or use a schematic variant that supports NgModule bootstrap.","Convert the entry manually: replace bootstrapModule with `bootstrapApplication(AppComponent, appConfig)`."],"exampleFix":"// before\nplatformBrowserDynamic().bootstrapModule(AppModule);\n// after\nbootstrapApplication(AppComponent, { providers: [...] });","handlingStrategy":"validation","validationCode":"const main = fs.readFileSync('src/main.ts', 'utf8');\nif (!/bootstrapApplication\\s*\\(/.test(main)) {\n  throw new Error('Entry file is not standalone-bootstrap; this schematic requires bootstrapApplication.');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify the app is standalone before using standalone-oriented schematics.","Point the angular.json main option at the file that actually calls bootstrapApplication.","Complete the standalone migration before running ng add of standalone-only libraries."],"tags":["angular","standalone","schematics","bootstrap"],"backgroundTag":"bootstrap-call-not-found","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}