angular/angular-cli · error · SchematicsException

Cannot find the "provideServerRendering" function call in "$

Error message

Cannot find the "provideServerRendering" function call in "${configFilePath}".

What it means

Once the server config file is located, the schematic parses it with the TypeScript AST and searches for a `provideServerRendering(...)` call expression to append `withAppShell(AppShell)`. If no such call is found in the file, it throws, meaning the server config does not use the expected standalone `provideServerRendering` API.

Source

Thrown at packages/schematics/angular/app-shell/index.ts:182

      ? join(project.sourceRoot ?? 'src', 'app/app.config.server.ts')
      : getServerModulePath(host, project.sourceRoot || 'src', 'main.server.ts');

    if (!configFilePath || !host.exists(configFilePath)) {
      throw new SchematicsException(`Cannot find "${configFilePath}".`);
    }

    const configSourceFile = getSourceFile(host, configFilePath);
    const functionCall = findNodes(
      configSourceFile,
      ts.isCallExpression,
      /** max */ undefined,
      /** recursive */ true,
    ).find(
      (n) => ts.isIdentifier(n.expression) && n.expression.getText() === 'provideServerRendering',
    );

    if (!functionCall) {
      throw new SchematicsException(
        `Cannot find the "provideServerRendering" function call in "${configFilePath}".`,
      );
    }

    const recorder = host.beginUpdate(configFilePath);
    recorder.insertLeft(functionCall.end - 1, `, withAppShell(AppShell)`);

    applyToUpdateRecorder(recorder, [
      insertImport(configSourceFile, configFilePath, 'withAppShell', '@angular/ssr'),
      insertImport(configSourceFile, configFilePath, 'AppShell', './app-shell/app-shell'),
    ]);

    host.commitUpdate(recorder);
  };
}

const appShellSchematic: RuleFactory<AppShellOptions> = createProjectSchematic(
  async (options, { tree }) => {

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Update the server config to bootstrap with `provideServerRendering(...)` from @angular/platform-server (current API)
  2. Re-run `ng add @angular/ssr` to regenerate a canonical app.config.server.ts, then re-run app-shell
  3. Alternatively add `withAppShell(() => import('./app/app-shell/app-shell.component'))` to the provideServerRendering arguments by hand

Example fix

// before
export default () => ServerModule.forRoot(...);
// after
export default provideServerRendering(withRoutes(routes), withAppShell(AppShell));
Defensive patterns

Strategy: validation

Validate before calling

const src = fs.readFileSync('src/app/app.config.server.ts', 'utf8');
if (!/provideServerRendering\s*\(/.test(src)) {
  throw new Error('app.config.server.ts must call provideServerRendering(...)');
}

Try / catch

try {
  await ngGenerate('app-shell', options);
} catch (e) {
  if (e.message.includes('provideServerRendering')) {
    console.error('Server config uses an outdated/aliased API; migrate to provideServerRendering');
  } else throw e;
}

Prevention

When it happens

Trigger: app.config.server.ts bootstraps server rendering differently — e.g. an outdated `ServerModule`-based AppServerModule, a renamed/aliased import, or the call exists in a different file than configFilePath.

Common situations: Projects generated before the withAppShell API; manual server setup copying old NgModule patterns into a standalone project; import aliasing (`import { provideServerRendering as psr }`) that defeats the identifier text check.

Related errors


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