vitest-dev/vitest · error · Error

No projects were found. Make sure your configuration is corr

Error message

No projects were found. Make sure your configuration is correct. ${globalConfig.project.length ? `The filter matched no projects: ${globalConfig.project.join(', ')}. ` : ''}The projects definition: ${JSON.stringify(definitions.map((p, index) => typeof p === 'string' ? p : p instanceof Promise ? 'Promise' : typeof p === 'function' ? p.name : ({ name: p.test?.name ?? index })), null, 4)}.

What it means

Thrown at the end of resolution (resolveProjects.ts:198-216) when projects were declared (definitions is truthy) but after browser/benchmark expansion and the --project filter, no visible entry remains. The message echoes the --project filter (if any) and a JSON dump of the raw definitions so you can see what was tried.

Source

Thrown at packages/vitest/src/node/projects/resolveProjects.ts:199

  const seenNamesSet = new Set(seenNames.keys())

  // Browser instance expansion (per-entry config injection).
  const afterBrowser = expandBrowserInstancesInEntries(globalConfig, baseEntries, seenNamesSet)

  // Benchmark expansion (per-entry config injection, runs over post-browser list).
  // `--benchmark` makes every project run as a benchmark.
  const afterBenchmark = expandBenchmarksInEntries(afterBrowser, seenNamesSet, !!globalConfig.cliOptions.benchmarkOnly)

  // --project filter (applied after expansion so all candidate names are known).
  const filtered = applyProjectFilter(globalConfig, afterBenchmark)

  // If the user declared `projects` (or workspace files) but the filter
  // excluded every candidate, throw with the projects definition included so
  // callers see what was tried. Skipped for the runtime `injectTestProjects`
  // path where filtering injected projects out is expected.
  const filterMatched = filtered.some(entry => !entry.hidden)
  if (throwIfEmpty && definitions && !filterMatched) {
    throw new Error(
      [
        'No projects were found. Make sure your configuration is correct. ',
        globalConfig.project.length ? `The filter matched no projects: ${globalConfig.project.join(', ')}. ` : '',
        `The projects definition: ${JSON.stringify(
          definitions.map((p, index) => typeof p === 'string'
            ? p
            : p instanceof Promise
              ? 'Promise'
              : typeof p === 'function'
                ? p.name
                : ({ name: p.test?.name ?? index })),
          null,
          4,
        )}.`,
      ].join(''),
    )
  }

View on GitHub (pinned to d568f8ce37)

Solutions

  1. Drop or correct the --project filter so it matches at least one resolved project name.
  2. Verify the projects globs/paths actually match files (run a dry glob yourself).
  3. If projects: [] was set by mistake, remove it or provide at least one definition.
  4. Inspect the dumped definitions JSON in the error to confirm names match your filter (use the same casing/label).

Example fix

// before
export default defineConfig({ test: { projects: ['packages/*/vitest.config.ts'] } })
// run: vitest --project=unit  (no project named 'unit')

// after: either fix the filter or the glob
vitest --project=web  // matches a real project name
Defensive patterns

Strategy: validation

Validate before calling

if (definitions.length === 0 && throwIfEmpty) {
  throw new Error('projects array is empty')
}
const resolvedNames = entries.map(e => e.projectConfig.name)
if (filter.length && !resolvedNames.some(n => matchesProjectFilter(filter, n))) {
  throw new Error(`--project filter '${filter}' matches none of: ${resolvedNames.join(', ')}`)
}

Type guard

function filterMatchesAny(filter: string[], names: string[]): boolean {
  return names.some(n => matchesProjectFilter(filter, n))
}

Prevention

When it happens

Trigger: The projects array resolves to zero entries (e.g. globs match nothing); every project is hidden by an overly narrow --project filter; all definitions are Promises that reject (those surface in 287 instead) or filter out; definitions reference paths that produce no project.

Common situations: Running vitest --project=nonexistent where nonexistent matches nothing; a glob like 'packages/*/vitest.config.ts' in a repo with no such files; renaming projects but keeping an old --project flag in CI; misconfigured projects: [] (empty array treated as empty workspace).

Related errors


AI-assisted analysis of vitest-dev/vitest@d568f8ce37 (2026-08-03). Data as JSON: /data/errors/21947d942de90f01.json. Report an issue: GitHub.