angular/angular-cli · error · SchematicsException

Cannot update project "${projectName}" to use the applicatio

Error message

Cannot update project "${projectName}" to use the application builder as the server tsconfig cannot be located.

What it means

Thrown by the use-application-builder migration when converting a legacy browser/server (Universal) project to the application builder. The migration located the browser tsconfig but could not resolve the server tsconfig to a string path, so it cannot rewire build options safely and aborts the project update.

Source

Thrown at packages/schematics/angular/migrations/use-application-builder/migration.ts:116

    delete options['buildOptimizer'];
    delete options['main'];
    delete options['ngswConfigPath'];
  }

  // Merge browser and server tsconfig
  if (serverTarget) {
    const browserTsConfig = buildTarget.options?.tsConfig;
    const serverTsConfig = serverTarget.options?.tsConfig;

    if (typeof browserTsConfig !== 'string') {
      throw new SchematicsException(
        `Cannot update project "${projectName}" to use the application builder` +
          ` as the browser tsconfig cannot be located.`,
      );
    }

    if (typeof serverTsConfig !== 'string') {
      throw new SchematicsException(
        `Cannot update project "${projectName}" to use the application builder` +
          ` as the server tsconfig cannot be located.`,
      );
    }

    const browserJson = new JSONFile(tree, browserTsConfig);
    const serverJson = new JSONFile(tree, serverTsConfig);

    const filesPath = ['files'];

    const files = new Set([
      ...((browserJson.get(filesPath) as string[] | undefined) ?? []),
      ...((serverJson.get(filesPath) as string[] | undefined) ?? []),
    ]);

    // Server file will be added later by the means of the ssr schematic.
    files.delete('server.ts');

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Open angular.json and ensure the server build target has a valid 'tsConfig' option pointing to an existing tsconfig file (e.g. tsconfig.server.json).
  2. If SSR was removed, delete the server build target and related architect targets before re-running the migration.
  3. Recreate tsconfig.server.json (or run `ng add @angular/ssr`) so the server tsconfig exists, then re-run the migration.
  4. Verify the referenced tsconfig file exists on disk at the path given in angular.json.

Example fix

// before (angular.json)
"server": { "options": { "main": "server.ts" } }
// after
"server": { "options": { "main": "server.ts", "tsConfig": "tsconfig.server.json" } }
Defensive patterns

Strategy: validation

Validate before calling

const serverTs = project.architect?.server?.options?.tsConfig;
if (typeof serverTs !== 'string' || !fs.existsSync(serverTs)) {
  throw new Error(`Server tsconfig missing for project; fix angular.json before migrating.`);
}

Type guard

function hasServerTsConfig(p: any): p is { architect: { server: { options: { tsConfig: string } } } } {
  return typeof p?.architect?.server?.options?.tsConfig === 'string';
}

Try / catch

try {
  await runMigration('use-application-builder');
} catch (e) {
  if (String(e.message).includes('server tsconfig cannot be located')) {
    logger.warn('Fix the server target tsConfig in angular.json and re-run.');
  } else throw e;
}

Prevention

When it happens

Trigger: Running `ng update` / the use-application-builder migration on a project that has a server builder configured (e.g. @angular-devkit/build-angular:server) but whose server tsconfig path cannot be resolved from the build target options (missing/renamed 'tsConfig' option, or pointing to a nonexistent file).

Common situations: Projects upgraded across multiple Angular major versions where server tsconfig was renamed (tsconfig.server.json moved or deleted); hand-edited angular.json with server target options lacking tsConfig; Universal/SSR setups partially removed.

Related errors


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