vitejs/vite · error · Error
failed to resolve rolldownOptions.input value: ${JSON.string
Error message
failed to resolve rolldownOptions.input value: ${JSON.stringify(p)}. What it means
Thrown during dependency scanning when `build.rolldownOptions.input` (or environment `input`) references a path that the Vite plugin container cannot resolve. Vite uses these inputs as scan entry points, so every entry must resolve to a real on-disk module or a plugin-provided virtual id. The error includes the offending path verbatim so you can see which input failed.
Source
Thrown at packages/vite/src/node/optimizer/scan.ts:231
async function computeEntries(environment: ScanEnvironment) {
let entries: string[] = []
const explicitEntryPatterns = environment.config.optimizeDeps.entries
const input =
environment.config.input ?? environment.config.build.rolldownOptions.input
if (explicitEntryPatterns) {
entries = await globEntries(explicitEntryPatterns, environment)
} else if (input) {
const resolvePath = async (p: string) => {
const id = (
await environment.pluginContainer.resolveId(p, undefined, {
isEntry: true,
scan: true,
})
)?.id
if (id === undefined) {
throw new Error(
`failed to resolve rolldownOptions.input value: ${JSON.stringify(p)}.`,
)
}
return id
}
if (typeof input === 'string') {
entries = [await resolvePath(input)]
} else if (Array.isArray(input)) {
entries = await Promise.all(input.map(resolvePath))
} else if (isObject(input)) {
entries = await Promise.all(Object.values(input).map(resolvePath))
} else {
throw new Error('invalid rolldownOptions.input value.')
}
} else {
entries = await globEntries('**/*.html', environment)
}
View on GitHub (pinned to 89620f09af)
Solutions
- Verify the path printed in the message exists on disk and is spelled correctly.
- Make sure each entry is resolvable from the project root (use a relative path like './src/main.ts' or an absolute path).
- If the entry is virtual or non-standard, add a plugin `resolveId` hook that returns an id for it (with `scan: true` in the options).
- If you do not need explicit scan entries, remove `build.rolldownOptions.input` and instead set `optimizeDeps.entries` to a glob.
Example fix
// before (vite.config.ts)
export default defineConfig({
build: { rolldownOptions: { input: './src/main.tx' } }, // typo
});
// after
export default defineConfig({
build: { rolldownOptions: { input: './src/main.ts' } },
}); Defensive patterns
Strategy: validation
Validate before calling
import { existsSync } from 'node:fs';
import path from 'node:path';
function validateInputs(input, root) {
const values =
typeof input === 'string'
? [input]
: Array.isArray(input)
? input
: input && typeof input === 'object'
? Object.values(input)
: [];
for (const p of values) {
if (!existsSync(path.resolve(root, p))) {
throw new Error(`rolldownOptions.input does not exist: ${p}`);
}
}
}
// call before build: validateInputs(config.build.rolldownOptions?.input, config.root); Type guard
function isViteInput(v) {
return (
typeof v === 'string' ||
(Array.isArray(v) && v.every((x) => typeof x === 'string')) ||
(v != null && typeof v === 'object' &&
Object.values(v).every((x) => typeof x === 'string'))
);
} Try / catch
try {
await build();
} catch (e) {
if (/failed to resolve rolldownOptions\.input value/.test(e.message)) {
const bad = e.message.match(/value: (.*)\.$/)?.[1];
console.error('Fix or remove this input entry:', bad);
}
throw e;
} Prevention
- Treat entry paths as code: keep them in config and lint them in CI.
- Prefer relative entry paths and assert they resolve in a prebuild script.
- Use TypeScript for vite.config and rely on the typed `InputOption` to catch shape mistakes.
When it happens
Trigger: In `computeEntries`, when `optimizeDeps.entries` is unset but `input` is configured, each input value is run through `pluginContainer.resolveId(p, undefined, { isEntry: true, scan: true })`. If that call returns `undefined` (no resolver claimed the id), the error is thrown.
Common situations: Typo in an entry path, entry pointing outside the project root without an alias, referencing a file that was deleted/moved, a virtual module id that no plugin handles during scan, or an absolute path whose extension is filtered out by `isScannable`.
Related errors
- Either "build.lib.entry" or the top-level "input" option is
- rolldownOptions.input should not be an html file when buildi
- When "build.cssCodeSplit: false" is set, "rolldownOptions.in
- invalid rolldownOptions.input value.
- Invalid glob: "${glob}" (resolved: "${resolved}"). It must s
AI-assisted analysis of vitejs/vite@89620f09af (2026-08-03).
Data as JSON: /data/errors/2f81105f1612efa2.json.
Report an issue: GitHub.