cypress-io/cypress · error · Error
Your component devServer config for vite is missing a requir
Error message
Your component devServer config for vite is missing a required viteConfig property, since we could not automatically detect one.\n Please add one to your ${config.cypressConfig.configFile} What it means
Thrown by resolveConfig when no explicit viteConfig was passed to devServer AND findUp could not locate any Vite config file (the configFiles list) walking up from projectRoot, AND config.onConfigNotFound is not provided. Cypress tries to auto-detect vite.config.{js,ts,mjs,...}; if none exists and there is no custom not-found handler, it cannot build a Vite config and aborts, pointing you to your cypress config file.
Source
Thrown at npm/vite-dev-server/src/resolveConfig.ts:62
} else if (typeof inlineViteConfig === 'object') {
resolvedOverrides = inlineViteConfig
}
// Set "configFile: false" to disable auto resolution of <project-root>/vite.config.js
resolvedOverrides = { configFile: false, ...resolvedOverrides }
} else {
const { findUp } = await import('find-up')
const configFile = await findUp(configFiles, { cwd: projectRoot })
if (!configFile) {
if (config.onConfigNotFound) {
config.onConfigNotFound('vite', projectRoot, configFiles)
// The config process will be killed from the parent, but we want to early exit so we don't get
// any additional errors related to not having a config
process.exit(0)
} else {
throw new Error(`Your component devServer config for vite is missing a required viteConfig property, since we could not automatically detect one.\n Please add one to your ${config.cypressConfig.configFile}`)
}
}
debug('Resolved config file at', configFile, 'using root', projectRoot)
resolvedOverrides = { configFile }
}
const finalConfig = vite.mergeConfig(
resolvedOverrides,
makeCypressViteConfig(config, vite),
)
debug('The resolved server config is', JSON.stringify(finalConfig, null, 2))
return finalConfig
}
View on GitHub (pinned to 0d85fdc912)
Solutions
- Create a vite.config.{js,ts,mjs} at or above your cypressConfig.projectRoot.
- Or pass an explicit config: `devServer: { bundler: 'vite', viteConfig: { ... } }` (object or async function).
- If you intentionally have no config, provide `devServer: { bundler: 'vite', viteConfig: { configFile: false } }` to skip auto-detection.
- Supply onConfigNotFound in the devServer config to customize the missing-config path instead of throwing.
Example fix
// before
devServer: { bundler: 'vite' } // and no vite.config.* exists
// after — option A: pass inline config
devServer: { bundler: 'vite', viteConfig: { server: { port: 5173 } } }
// after — option B: create vite.config.ts at project root
import { defineConfig } from 'vite'
export default defineConfig({}) Defensive patterns
Strategy: validation
Validate before calling
import { existsSync } from 'fs'
import { findUp } from 'find-up'
const hasViteConfig = async (root: string) => !!(await findUp(['vite.config.ts','vite.config.js','vite.config.mjs'], { cwd: root }))
if (!(await hasViteConfig(projectRoot)) && !devServerConfig.viteConfig) throw new Error('Provide viteConfig or create vite.config.*') Type guard
const hasInlineViteConfig = (c: any): boolean => !!c?.viteConfig
Prevention
- Always pass viteConfig explicitly or keep a vite.config.* discoverable from projectRoot.
- Provide onConfigNotFound in the devServer config to customize the missing-config path.
- Document the expected config file location for your monorepo layout.
When it happens
Trigger: Configuring CT with `devServer: { bundler: 'vite' }` (no viteConfig) in a project that has no vite.config.* anywhere from projectRoot upward, and without supplying an onConfigNotFound callback in the devServer config.
Common situations: Adopting Cypress CT in a project that uses a non-standard config location (e.g. vite.config.js in a subfolder), a monorepo where vite config lives at the root but the spec projectRoot is deeper than findUp reaches, or a brand-new project with no Vite config yet.
Related errors
- Missing vite dev server port.
- Could not read '${path}'.
- ${err}
- CJS builds of vite ${majorVersionNumber} are not supported
- Could not find "vite" in your project's dependencies. Please
AI-assisted analysis of cypress-io/cypress@0d85fdc912 (2026-08-12).
Data as JSON: /api/errors/2815b82cab6b0611.
Report an issue: GitHub.