angular/angular-cli · error · SchematicsException

Project name "${options.project}" doesn't not exist.

Error message

Project name "${options.project}" doesn't not exist.

What it means

The `environments` schematic resolves `options.project` in the workspace and throws this SchematicsException when the name does not match any project in angular.json. Like the config schematic, it refuses to proceed for unknown projects since it must locate the project's source root to generate `environment.ts`/`environment.development.ts` files.

Source

Thrown at packages/schematics/angular/environments/index.ts:22

 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.dev/license
 */

import { Rule, SchematicsException, chain } from '@angular-devkit/schematics';
import { posix as path } from 'node:path';
import { TargetDefinition, updateWorkspace } from '../utility/workspace';
import { Builders as AngularBuilder } from '../utility/workspace-models';
import { Schema as EnvironmentOptions } from './schema';

const ENVIRONMENTS_DIRECTORY = 'environments';
const ENVIRONMENT_FILE_CONTENT = 'export const environment = {};\n';

export default function (options: EnvironmentOptions): Rule {
  return updateWorkspace((workspace) => {
    const project = workspace.projects.get(options.project);
    if (!project) {
      throw new SchematicsException(`Project name "${options.project}" doesn't not exist.`);
    }

    const type = project.extensions['projectType'];
    if (type !== 'application') {
      return log(
        'error',
        'Only application project types are support by this schematic.' + type
          ? ` Project "${options.project}" has a "projectType" of "${type}".`
          : ` Project "${options.project}" has no "projectType" defined.`,
      );
    }

    const buildTarget = project.targets.get('build');
    if (!buildTarget) {
      return log(
        'error',
        `No "build" target found for project "${options.project}".` +
          ' A "build" target is required to generate environment files.',

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Open angular.json and pass the exact project key: `ng g environments --project <exact-name>`.
  2. Run the command from the workspace root so the correct angular.json is read.
  3. If the project was renamed, update scripts or restore the original project entry.

Example fix

// before
ng g environments --project front-end-app   // registered as "frontend-app"
// after
ng g environments --project frontend-app
Defensive patterns

Strategy: validation

Validate before calling

const angularJson = JSON.parse(tree.read('angular.json')!.toString('utf8'));
if (!angularJson.projects?.[options.project]) {
  throw new Error(`Project "${options.project}" does not exist in this workspace`);
}

Type guard

function hasProject(name: string, w: { projects: Record<string, unknown> }): boolean {
  return !!w.projects[name];
}

Try / catch

try {
  await runSchematic('environments', { project });
} catch (e) {
  if (e instanceof SchematicsException && e.message.includes('doesn\'t not exist')) {
    console.error(`No project "${project}" — list keys under "projects" in angular.json.`);
  } else throw e;
}

Prevention

When it happens

Trigger: Running `ng generate environments --project <name>` where `<name>` is not an exact key in the workspace `projects` map — typos, wrong casing, npm package names, or a project removed/renamed in angular.json.

Common situations: Multi-project (Nx-style or Angular workspace) users passing the wrong project; scripts referencing old project names after restructure; running the schematic outside the workspace root so the wrong angular.json is loaded.

Related errors


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