angular/angular-cli · error · SchematicsException

Multiple projects found: [${projectNames.join(', ')}]. Pleas

Error message

Multiple projects found: [${projectNames.join(', ')}]. Please specify a project name.

What it means

Thrown by the jasmine-vitest refactor helper's getProject when no --project name was supplied and the workspace contains more than one project, making the target ambiguous. It refuses to guess which project's tests to migrate.

Source

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

  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']);

function findTestFiles(directory: DirEntry, fileSuffix: string): string[] {
  const files: string[] = [];
  const stack: DirEntry[] = [directory];

  let current: DirEntry | undefined;
  while ((current = stack.pop())) {
    for (const path of current.subfiles) {
      if (path.endsWith(fileSuffix)) {
        files.push(current.path + '/' + path);
      }
    }

View on GitHub (pinned to bb72145f9a)

Solutions

  1. Re-run with an explicit --project=<name>.
  2. Run the refactor once per project, each with its own --project flag.
  3. If only one project is actually relevant, temporarily scope the workspace or use a path-scoped include.
  4. Check `ng list` output for the exact project names to pass.

Example fix

// before
ng ref jasmine-vitest
// after
ng ref jasmine-vitest --project admin
Defensive patterns

Strategy: validation

Validate before calling

const ws = JSON.parse(fs.readFileSync('angular.json', 'utf8'));
const names = Object.keys(ws.projects || {});
if (!projectName && names.length > 1) {
  throw new Error(`Workspace has multiple projects (${names.join(', ')}); pass --project.`);
}

Try / catch

try {
  await runJasmineVitestRefactor(opts);
} catch (e) {
  if (String(e.message).startsWith('Multiple projects found')) {
    const projects = e.message.match(/\[(.*)\]/)?.[1].split(', ') ?? [];
    console.error('Specify --project. Candidates:', projects);
  } else throw e;
}

Prevention

When it happens

Trigger: Running the jasmine-vitest refactor without --project in a multi-project workspace (multiple entries in workspace.projects), after getProject found no explicit name and more than one candidate.

Common situations: Nx/monorepo-style Angular workspaces with several applications/libraries; running a repo-wide script that omits --project; workspaces that grew from one app to many.

Related errors


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