{"record":{"id":"db3eda568a0f670b","repo":"angular/angular-cli","slug":"cannot-find-the-provideserverrendering-function","errorCode":null,"errorMessage":"Cannot find the \"provideServerRendering\" function call in \"${configFilePath}\".","messagePattern":"Cannot find the \"provideServerRendering\" function call in \"(.+?)\"\\.","errorType":"exception","errorClass":"SchematicsException","httpStatus":null,"severity":"error","filePath":"packages/schematics/angular/app-shell/index.ts","lineNumber":182,"sourceCode":"      ? join(project.sourceRoot ?? 'src', 'app/app.config.server.ts')\n      : getServerModulePath(host, project.sourceRoot || 'src', 'main.server.ts');\n\n    if (!configFilePath || !host.exists(configFilePath)) {\n      throw new SchematicsException(`Cannot find \"${configFilePath}\".`);\n    }\n\n    const configSourceFile = getSourceFile(host, configFilePath);\n    const functionCall = findNodes(\n      configSourceFile,\n      ts.isCallExpression,\n      /** max */ undefined,\n      /** recursive */ true,\n    ).find(\n      (n) => ts.isIdentifier(n.expression) && n.expression.getText() === 'provideServerRendering',\n    );\n\n    if (!functionCall) {\n      throw new SchematicsException(\n        `Cannot find the \"provideServerRendering\" function call in \"${configFilePath}\".`,\n      );\n    }\n\n    const recorder = host.beginUpdate(configFilePath);\n    recorder.insertLeft(functionCall.end - 1, `, withAppShell(AppShell)`);\n\n    applyToUpdateRecorder(recorder, [\n      insertImport(configSourceFile, configFilePath, 'withAppShell', '@angular/ssr'),\n      insertImport(configSourceFile, configFilePath, 'AppShell', './app-shell/app-shell'),\n    ]);\n\n    host.commitUpdate(recorder);\n  };\n}\n\nconst appShellSchematic: RuleFactory<AppShellOptions> = createProjectSchematic(\n  async (options, { tree }) => {","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/schematics/angular/app-shell/index.ts#L164-L200","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Update the server config to bootstrap with `provideServerRendering(...)` from @angular/platform-server (current API)","Re-run `ng add @angular/ssr` to regenerate a canonical app.config.server.ts, then re-run app-shell","Alternatively add `withAppShell(() => import('./app/app-shell/app-shell.component'))` to the provideServerRendering arguments by hand"],"exampleFix":"// before\nexport default () => ServerModule.forRoot(...);\n// after\nexport default provideServerRendering(withRoutes(routes), withAppShell(AppShell));","handlingStrategy":"validation","validationCode":"const src = fs.readFileSync('src/app/app.config.server.ts', 'utf8');\nif (!/provideServerRendering\\s*\\(/.test(src)) {\n  throw new Error('app.config.server.ts must call provideServerRendering(...)');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await ngGenerate('app-shell', options);\n} catch (e) {\n  if (e.message.includes('provideServerRendering')) {\n    console.error('Server config uses an outdated/aliased API; migrate to provideServerRendering');\n  } else throw e;\n}","preventionTips":["Use the current @angular/platform-server provideServerRendering API (not legacy ServerModule)","Avoid renaming imports of provideServerRendering (aliases defeat AST matching)","Regenerate server config via `ng add @angular/ssr` on older projects"],"tags":["angular","ssr","schematics","ast"],"backgroundTag":"provideserverrendering-not-found","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}