vitest-dev/vitest · error · Error
Project name "${name}"${entryFile ? ` from "${entryFile}"` :
Error message
Project name "${name}"${entryFile ? ` from "${entryFile}"` : ''} is not unique.${existingFile ? ` The project is already defined by "${existingFile}".` : ''}${filesError}All projects should have unique names. Make sure your configuration is correct. What it means
The detailed duplicate-name error (resolveProjects.ts:150-178), thrown when two entries resolved in the same batch share a project name. It augments the message with the config files that produced each entry and, when multiple file-based entries exist, lists every config file considered so you can see which file matched unexpectedly.
Source
Thrown at packages/vitest/src/node/projects/resolveProjects.ts:170
// inline entries carry the configFile they extend, which doesn't say
// where the project is declared, so they are reported without a file
const entryFile = !entry.inline && entry.viteConfig.configFile
? relative(globalConfig.root, entry.viteConfig.configFile)
: ''
const existingFile = !existing.inline && existing.viteConfig.configFile
? relative(globalConfig.root, existing.viteConfig.configFile)
: ''
const filesError = baseEntries.length > 1 && (entryFile || existingFile)
? [
'\n\nYour config matched these files:\n',
baseEntries
.filter(e => !e.inline && e.viteConfig.configFile)
.map(e => ` - ${relative(globalConfig.root, e.viteConfig.configFile as string)}`)
.join('\n'),
'\n\n',
].join('')
: ' '
throw new Error([
`Project name "${name}"`,
entryFile ? ` from "${entryFile}"` : '',
' is not unique.',
existingFile ? ` The project is already defined by "${existingFile}".` : '',
filesError,
'All projects should have unique names. Make sure your configuration is correct.',
].join(''))
}
seenNames.set(name, entry)
}
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)View on GitHub (pinned to d568f8ce37)
Solutions
- Give each project an explicit unique test.name in its config.
- If using auto-naming, fix duplicate package.json names or directory basenames.
- Inspect the listed config files to find which entries collided and remove or rename the duplicate.
- For globs, tighten the pattern so only one entry per intended project matches.
Example fix
// before: both packages auto-named 'core' via package.json
export default defineConfig({ test: { projects: ['packages/core-old', 'packages/core-new'] } })
// after
export default defineConfig({
test: {
projects: [
{ test: { name: 'core-old', root: 'packages/core-old' } },
{ test: { name: 'core-new', root: 'packages/core-new' } },
],
},
}) Defensive patterns
Strategy: validation
Validate before calling
const names = definitions.map(d => typeof d === 'string' ? basename(dirname(d)) : (d as any).test?.name ?? '(auto)')
const dupes = names.filter((n, i) => names.indexOf(n) !== i)
if (dupes.length) throw new Error(`Duplicate project names: ${[...new Set(dupes)].join(', ')}`) Type guard
function allUnique<T>(arr: T[]): boolean {
return new Set(arr).size === arr.length
} Prevention
- Set explicit, unique test.name on every project config.
- In monorepos, ensure package.json names differ.
- For globs, sanity-check the matched directories' names before running.
When it happens
Trigger: Two inline project configs with the same test.name; two config files whose package.json name / directory basename resolve identically; a glob like 'packages/*' matching multiple directories that each fall back to the same auto-name; the same config file referenced twice.
Common situations: Monorepo where two packages have the same name in their package.json; renaming a package but forgetting the workspace entry; a glob that matches both a directory and a sibling config file producing the same resolved name; explicit test.name reused across entries.
Related errors
- Project name "${name}" is not unique. All projects should ha
- Cannot define a nested project for a ${browser} browser. The
- Cannot create a benchmark project because the name "${name}"
- The file "${relative(parentConfig.root, file)}" must start w
- No projects were found. Make sure your configuration is corr
AI-assisted analysis of vitest-dev/vitest@d568f8ce37 (2026-08-03).
Data as JSON: /data/errors/ae9626a1e7aa4658.json.
Report an issue: GitHub.