vitest-dev/vitest · error · Error
Vitest standalone mode requires --watch
Error message
Vitest standalone mode requires --watch
What it means
Standalone mode keeps Vitest's server alive so other tools (e.g. an editor) can attach and trigger runs; it is meaningless without watch because there would be no re-run trigger and the process would just exit. The guard at resolveConfig.ts:344 forces --watch whenever --standalone is set.
Source
Thrown at packages/vitest/src/node/config/resolveConfig.ts:345
const [indexString, countString] = options.shard.split('/')
const index = Math.abs(Number.parseInt(indexString, 10))
const count = Math.abs(Number.parseInt(countString, 10))
if (Number.isNaN(count) || count <= 0) {
throw new Error('--shard <count> must be a positive number')
}
if (Number.isNaN(index) || index <= 0 || index > count) {
throw new Error(
'--shard <index> must be a positive number less then <count>',
)
}
resolved.shard = { index, count }
}
if (resolved.standalone && !resolved.watch) {
throw new Error(`Vitest standalone mode requires --watch`)
}
if (resolved.mergeReports && resolved.watch) {
throw new Error(`Cannot merge reports with --watch enabled`)
}
if (resolved.maxWorkers) {
resolved.maxWorkers = resolveInlineWorkerOption(resolved.maxWorkers)
}
// `browser.fileParallelism` was replaced by the top-level `fileParallelism`. Map
// it (only when browser is enabled, since it was a browser-only option) so
// existing configs keep working instead of being silently ignored.
const browserOptions = options.browser as { enabled?: boolean; fileParallelism?: boolean } | undefined
const browserFileParallelism = browserOptions?.enabled ? browserOptions.fileParallelism : undefined
if (browserFileParallelism !== undefined) {
logger.deprecate('`browser.fileParallelism` is deprecated. Use the top-level `fileParallelism` option instead.')
}View on GitHub (pinned to d568f8ce37)
Solutions
- Always pair standalone with watch: `vitest --standalone --watch`.
- If you do not need a persistent server, drop --standalone and run vitest normally.
- Configure your editor plugin to pass both flags.
Example fix
# before vitest --standalone # after vitest --standalone --watch
Defensive patterns
Strategy: validation
Validate before calling
function assertStandaloneHasWatch(opts: { standalone?: boolean; watch?: boolean }) {
if (opts.standalone && !opts.watch) throw new Error('--standalone requires --watch')
} Prevention
- Always pass --watch with --standalone.
- Configure editor integrations to set both flags.
- Do not use standalone in CI one-shot pipelines.
When it happens
Trigger: Run `vitest --standalone` without --watch, or set `standalone: true` while `watch: false`.
Common situations: Trying standalone in a CI one-shot context; editor integration that forgot to enable watch.
Related errors
- You cannot use --shard option with enabled watch
- Cannot merge reports with --watch enabled
- --shard <count> must be a positive number
- --shard <index> must be a positive number less then <count>
- You cannot use ${inspectOption} without "--no-file-paralleli
AI-assisted analysis of vitest-dev/vitest@d568f8ce37 (2026-08-03).
Data as JSON: /data/errors/1848b3f2ad775ad3.json.
Report an issue: GitHub.