vitejs/vite · error · Error
`input` cannot contain glob characters. They are reserved…
Error message
`input` cannot contain glob characters. They are reserved, so the ${JSON.stringify(value)} is not allowed. Please escape them with a backslash (\) What it means
When Vite normalizes build.rollupOptions.input it calls unescapeGlobCharacters, which uses isDynamicPattern to detect glob metacharacters (* ? [ ] { } ( ) ! + @ |). Because input keys are reserved for future glob support, Vite throws rather than silently misinterpreting them. The fix is to backslash-escape any literal metacharacter.
Solutions
- Backslash-escape each metacharacter in the input string, e.g. 'src/entries/\[name\].ts'.
- Rename the source file to avoid glob metacharacters if you control it.
- Pass input as an object whose values are escaped paths.
Example fix
// before
build: { rollupOptions: { input: 'src/entries/[name].ts' } }
// after
build: { rollupOptions: { input: 'src/entries/\\[name\\].ts' } } Defensive patterns
Strategy: validation
Validate before calling
const globChars = /[*?\[\]{}()!+@|]/;
function validateInput(value) {
const vals = Array.isArray(value) ? value : typeof value === 'object' ? Object.values(value) : [value];
return vals.map((v) => ({ value: v, ok: !globChars.test(String(v)) }));
} Type guard
function isGlobFree(value) {
const vals = Array.isArray(value) ? value : typeof value === 'object' ? Object.values(value) : [value];
return vals.every((v) => !/[*?\[\]{}()!+@|]/.test(String(v)));
} Prevention
- Backslash-escape literal glob metacharacters in input paths.
- Avoid bracketed/parameterized filenames for build entries.
When it happens
Trigger: Passing an input path that contains a literal *, ?, [], {}, etc. - e.g. a file named 'config[dev].ts' or 'v1@2.ts'. Most often from generated filenames or path templates.
Common situations: Build pipelines that pass parameterized paths (e.g. 'src/entries/[name].ts'); monorepo tools that produce bracketed paths; Windows builds with weird artifact names.
Related errors
- Environment " " is not defined in the config.
- failed to resolve rolldownOptions.input value
- Invalid glob: " " (resolved: " "). It must start with '/'…
- invalid rolldownOptions.input value.
- Multiple entry points are not supported when output formats…
AI-assisted analysis of vitejs/vite@b4d66fee14 (2026-08-11).
Data as JSON: /api/errors/04cea1d7270cd2a2.
Report an issue: GitHub.
Appendix: source
Thrown at packages/vite/src/node/config.ts:952
if (typeof input === 'string') {
return unescapeGlobCharacters(input)
}
if (Array.isArray(input)) {
return input.map(unescapeGlobCharacters)
}
const resolved: Record<string, string> = {}
for (const key in input) {
resolved[key] = unescapeGlobCharacters(input[key])
}
return resolved
}
const escapedGlobCharactersRE = /\\([*?[\]{}()!+@|])/g
function unescapeGlobCharacters(value: string): string {
if (isDynamicPattern(value)) {
// so that it could later be changed to accept globs without a breaking change
throw new Error(
`\`input\` cannot contain glob characters. They are reserved, ` +
`so the ${JSON.stringify(value)} is not allowed. Please escape them with a backslash (\\)`,
)
}
// unescape glob characters
return value.replace(escapedGlobCharactersRE, '$1')
}
export function resolveDevEnvironmentOptions(
dev: DevEnvironmentOptions | undefined,
environmentName: string | undefined,
consumer: 'client' | 'server' | undefined,
// Backward compatibility
preTransformRequest?: boolean,
): ResolvedDevEnvironmentOptions {
const resolved = mergeWithDefaults(
{
...configDefaults.dev,View on GitHub (pinned to b4d66fee14)