angular/angular-cli · error · SchematicsException

Project "${projectName}" not found.

Error message

Project "${projectName}" not found.

What it means

Thrown by the jasmine-vitest refactor helper's getProject when an explicit projectName is given but no project with that name exists in the workspace. The helper needs a ProjectDefinition to scope the test migration.

Source

Thrown at packages/schematics/angular/refactor/jasmine-vitest/index.ts:31

  SchematicsException,
  Tree,
} from '@angular-devkit/schematics';
import { join, normalize } from 'node:path/posix';
import { ProjectDefinition, getWorkspace } from '../../utility/workspace';
import { Schema } from './schema';
import { transformJasmineToVitest } from './test-file-transformer';
import { RefactorReporter } from './utils/refactor-reporter';

async function getProject(
  tree: Tree,
  projectName: string | undefined,
): Promise<{ project: ProjectDefinition; name: string }> {
  const workspace = await getWorkspace(tree);

  if (projectName) {
    const project = workspace.projects.get(projectName);
    if (!project) {
      throw new SchematicsException(`Project "${projectName}" not found.`);
    }

    return { project, name: projectName };
  }

  if (workspace.projects.size === 1) {
    const [name, project] = Array.from(workspace.projects.entries())[0];

    return { project, name };
  }

  const projectNames = Array.from(workspace.projects.keys());
  throw new SchematicsException(
    `Multiple projects found: [${projectNames.join(', ')}]. Please specify a project name.`,
  );
}

const DIRECTORIES_TO_SKIP = new Set(['node_modules', '.git', 'dist', '.angular']);

View on GitHub (pinned to bb72145f9a)

Solutions

  1. List workspace projects (`ng list` or read angular.json) and re-run with an exact project name.
  2. Fix the --project flag spelling.
  3. Remove the --project flag to let the tool auto-select when only one project exists.
  4. If the project was renamed, update angular.json or use the new name.

Example fix

// before
ng ref jasmine-vitest --project appp
// after
ng ref jasmine-vitest --project app
Defensive patterns

Strategy: validation

Validate before calling

const workspace = JSON.parse(fs.readFileSync('angular.json', 'utf8'));
const names = Object.keys(workspace.projects || {});
if (projectName && !names.includes(projectName)) {
  throw new Error(`Unknown project '${projectName}'. Known: ${names.join(', ')}`);
}

Type guard

function projectExists(ws: { projects: Record<string, unknown> }, name: string): boolean {
  return Object.prototype.hasOwnProperty.call(ws.projects, name);
}

Try / catch

try {
  await runJasmineVitestRefactor({ project: projectName });
} catch (e) {
  if (String(e.message).includes('not found')) {
    console.error(`Project '${projectName}' does not exist. Run 'ng list'.`);
  } else throw e;
}

Prevention

When it happens

Trigger: Calling the jasmine-to-vitest refactor with `--project <name>` (the `{ project, name: projectName }` call site) where <name> is misspelled or was renamed/removed from angular.json.

Common situations: Typos in the project name; running after a project was renamed in a workspace restructure; monorepo workspaces where the project lives in a different angular workspace root.

Related errors


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