sveltejs/kit · error · Error
Failed to load SvelteKit options from Vite config
Error message
Failed to load SvelteKit options from Vite config
What it means
SvelteKit loads its options by evaluating the Vite config (vite.config.js/ts) and extracting the sveltekit config from plugins. If that evaluation throws, validate_config prints the underlying error to the console in bold red and rethrows a stackless Error 'Failed to load SvelteKit options from Vite config'. The real cause is in the printed message above it.
Source
Thrown at packages/kit/src/core/config/index.js:216
"The `router.resolution` option cannot be 'server' if `output.bundleStrategy` is 'inline' or 'single'"
);
}
}
if (typeof config.adapter?.vite === 'function') {
validated.adapter.vite = config.adapter.vite({
config: validated
});
}
return validated;
} catch (e) {
const error = /** @type {Error} */ (e);
// Print a nicer version of the error to the console
console.log(styleText(['bold', 'red'], `\n${error.message}\n`));
throw stackless('Failed to load SvelteKit options from Vite config');
}
}
View on GitHub (pinned to 03f1687fe6)
Solutions
- Read the bold red error printed above this message — it names the actual failure — and fix vite.config.js/ts accordingly
- Run `npx vite --debug` or temporarily simplify vite.config to isolate the throwing plugin/import
- Ensure all packages imported by the Vite config are installed and compatible with the Vite version SvelteKit requires
- Move environment-dependent logic out of the config or provide defaults
Example fix
// before (vite.config.js)
import customPlugin from 'not-installed-plugin';
export default { plugins: [customPlugin()] };
// after
export default { plugins: [] }; // install the dependency or remove the import Defensive patterns
Strategy: try-catch
Validate before calling
node --input-type=module -e "await import('./vite.config.js').then(() => console.log('config OK'))" Try / catch
try {
const { svelteConfig } = await loadViteConfig();
} catch (e) {
console.error('Vite config failed:', e.message); // real cause printed by SvelteKit above
process.exit(1);
} Prevention
- Keep vite.config free of side effects and env dependencies
- Install all packages imported by the config
- Pin Vite to a version compatible with your SvelteKit release
- Smoke-test the config import in CI before builds
When it happens
Trigger: extract_svelte_config fails because vite.config.js throws at import time (bad import, syntax error, missing dependency), a plugin's config/resolveId hook throws, or the vite config uses APIs not available in the current Vite version.
Common situations: Typos or runtime errors inside vite.config.ts; importing a package that is not installed (e.g. using an ESM-only plugin from CJS config); environment variables read in the config that are undefined in CI; Vite major-version incompatibility after an upgrade.
Related errors
- ${file} is no longer used. Please pass configuration via the
- The SvelteKit Vite plugin ${keypath} should be an object wit
- The _headers file should be placed in the project root rathe
- The _redirects file should be placed in the project root rat
- routes.include must contain 100 or fewer routes
AI-assisted analysis of sveltejs/kit@03f1687fe6 (2026-09-02).
Data as JSON: /api/errors/462d2f0aad1332d5.
Report an issue: GitHub.