{"record":{"id":"7a0685ce59ffbd8d","repo":"angular/angular-cli","slug":"cannot-find-configfilepath","errorCode":null,"errorMessage":"Cannot find \"${configFilePath}\".","messagePattern":"Cannot find \"(.+?)\"\\.","errorType":"exception","errorClass":"SchematicsException","httpStatus":null,"severity":"error","filePath":"packages/schematics/angular/app-shell/index.ts","lineNumber":168,"sourceCode":"  })[0];\n\n  return property;\n}\n\nfunction addServerRoutingConfig(options: AppShellOptions, isStandalone: boolean): Rule {\n  return async (host: Tree) => {\n    const workspace = await getWorkspace(host);\n    const project = workspace.projects.get(options.project);\n    if (!project) {\n      throw new SchematicsException(`Project name \"${options.project}\" doesn't not exist.`);\n    }\n\n    const configFilePath = isStandalone\n      ? 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","sourceCodeStart":150,"sourceCodeEnd":186,"githubUrl":"https://github.com/angular/angular-cli/blob/bb72145f9ab45aee29f523236b3a25cd0813a841/packages/schematics/angular/app-shell/index.ts#L150-L186","documentation":"After resolving the project, `addServerRoutingConfig` computes the server configuration file path: for standalone apps `<sourceRoot>/app/app.config.server.ts`, otherwise the server module path derived from main.server.ts. If that path cannot be computed or the file does not exist on the schematic Tree, it throws.","triggerScenarios":"Running app-shell on a project with no server build configured (no main.server.ts / app.config.server.ts file present); server routing was never added (`ng add @angular/ssr` not run); sourceRoot misconfigured so the computed path doesn't exist.","commonSituations":"Trying to add an app shell before Angular SSR/server routing is set up; Nx/custom layouts where app.config.server.ts lives elsewhere; projects migrated to standalone but the server config file was deleted.","solutions":["Add Angular SSR/server routing first: `ng add @angular/ssr` (creates app.config.server.ts or AppServerModule)","Create the missing server config file manually and re-run the schematic","Verify project.sourceRoot in angular.json matches the actual directory layout"],"exampleFix":"// before\nng g app-shell  # no server routing configured\n// after\nng add @angular/ssr --project=my-app && ng g app-shell --project=my-app","handlingStrategy":"validation","validationCode":"const p = options.project;\nconst sourceRoot = workspace.projects[p].sourceRoot || 'src';\nconst serverCfg = path.join(sourceRoot, 'app/app.config.server.ts');\nif (!fs.existsSync(serverCfg) && !fs.existsSync(path.join(sourceRoot, 'main.server.ts'))) {\n  throw new Error('Server routing/SSR not configured; run ng add @angular/ssr first');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await ngGenerate('app-shell', options);\n} catch (e) {\n  if (e.message.startsWith('Cannot find \"')) {\n    console.error('Server config file missing — run ng add @angular/ssr before app-shell');\n  } else throw e;\n}","preventionTips":["Always run `ng add @angular/ssr` before generating an app shell","Verify sourceRoot in angular.json matches the real directory layout","Keep app.config.server.ts in its default location (src/app/) unless you update all tooling"],"tags":["angular","schematics","ssr","file-not-found"],"backgroundTag":"missing-server-config-file","analyzedSha":"bb72145f9ab45aee29f523236b3a25cd0813a841","analyzedAt":"2026-08-30T02:47:34.745Z","schemaVersion":2},"datasetVersion":"2026-08-30T03:17:51.788Z"}