angular/angular-cli · error · SchematicsException

Could not find bootstrapApplication call in ${mainFilePath}

Error message

Could not find bootstrapApplication call in ${mainFilePath}

What it means

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.

Source

Thrown at packages/schematics/angular/utility/standalone/util.ts:89

      if (
        ts.isCallExpression(node) &&
        ts.isIdentifier(node.expression) &&
        node.expression.text === localName
      ) {
        result = node;
      }

      if (!result) {
        node.forEachChild(walk);
      }
    });

    if (result) {
      return result;
    }
  }

  throw new SchematicsException(`Could not find bootstrapApplication call in ${mainFilePath}`);
}

/**
 * Finds the local name of an imported symbol. Could be the symbol name itself or its alias.
 * @param sourceFile File within which to search for the import.
 * @param name Actual name of the import, not its local alias.
 * @param moduleName Name of the module from which the symbol is imported.
 */
function findImportLocalName(
  sourceFile: ts.SourceFile,
  name: string,
  moduleName: string,
): string | null {
  for (const node of sourceFile.statements) {
    // Only look for top-level imports.
    if (
      !ts.isImportDeclaration(node) ||
      !ts.isStringLiteral(node.moduleSpecifier) ||

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Ensure the file configured as the project's main/browser entry contains a `bootstrapApplication` call.
  2. For NgModule apps, migrate to standalone (`ng generate @angular/core:standalone` migration) or use a schematic variant that supports NgModule bootstrap.
  3. Convert the entry manually: replace bootstrapModule with `bootstrapApplication(AppComponent, appConfig)`.

Example fix

// before
platformBrowserDynamic().bootstrapModule(AppModule);
// after
bootstrapApplication(AppComponent, { providers: [...] });
Defensive patterns

Strategy: validation

Validate before calling

const main = fs.readFileSync('src/main.ts', 'utf8');
if (!/bootstrapApplication\s*\(/.test(main)) {
  throw new Error('Entry file is not standalone-bootstrap; this schematic requires bootstrapApplication.');
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of angular/angular-cli@bb72145f9a (2026-08-30). Data as JSON: /api/errors/be8dfe2ee7d3733d. Report an issue: GitHub.