angular/angular-cli · error · SchematicsException

Cannot find " ".

Error message

Cannot find "${configFilePath}".

What it means

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.

Solutions

  1. Add Angular SSR/server routing first: `ng add @angular/ssr` (creates app.config.server.ts or AppServerModule)
  2. Create the missing server config file manually and re-run the schematic
  3. Verify project.sourceRoot in angular.json matches the actual directory layout

Example fix

// before
ng g app-shell  # no server routing configured
// after
ng add @angular/ssr --project=my-app && ng g app-shell --project=my-app
Defensive patterns

Strategy: validation

Validate before calling

const p = options.project;
const sourceRoot = workspace.projects[p].sourceRoot || 'src';
const serverCfg = path.join(sourceRoot, 'app/app.config.server.ts');
if (!fs.existsSync(serverCfg) && !fs.existsSync(path.join(sourceRoot, 'main.server.ts'))) {
  throw new Error('Server routing/SSR not configured; run ng add @angular/ssr first');
}

Try / catch

try {
  await ngGenerate('app-shell', options);
} catch (e) {
  if (e.message.startsWith('Cannot find "')) {
    console.error('Server config file missing — run ng add @angular/ssr before app-shell');
  } else throw e;
}

Prevention

When it happens

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

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

Related errors


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

Appendix: source

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

  })[0];

  return property;
}

function addServerRoutingConfig(options: AppShellOptions, isStandalone: boolean): Rule {
  return async (host: Tree) => {
    const workspace = await getWorkspace(host);
    const project = workspace.projects.get(options.project);
    if (!project) {
      throw new SchematicsException(`Project name "${options.project}" doesn't not exist.`);
    }

    const configFilePath = isStandalone
      ? 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}".`,
      );
    }

View on GitHub (pinned to bb72145f9a)