{"record":{"id":"462d2f0aad1332d5","repo":"sveltejs/kit","slug":"failed-to-load-sveltekit-options-from-vite-config","errorCode":null,"errorMessage":"Failed to load SvelteKit options from Vite config","messagePattern":"Failed to load SvelteKit options from Vite config","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/kit/src/core/config/index.js","lineNumber":216,"sourceCode":"\t\t\t\t\t\"The `router.resolution` option cannot be 'server' if `output.bundleStrategy` is 'inline' or 'single'\"\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\n\t\tif (typeof config.adapter?.vite === 'function') {\n\t\t\tvalidated.adapter.vite = config.adapter.vite({\n\t\t\t\tconfig: validated\n\t\t\t});\n\t\t}\n\n\t\treturn validated;\n\t} catch (e) {\n\t\tconst error = /** @type {Error} */ (e);\n\n\t\t// Print a nicer version of the error to the console\n\t\tconsole.log(styleText(['bold', 'red'], `\\n${error.message}\\n`));\n\n\t\tthrow stackless('Failed to load SvelteKit options from Vite config');\n\t}\n}\n","sourceCodeStart":198,"sourceCodeEnd":219,"githubUrl":"https://github.com/sveltejs/kit/blob/03f1687fe612ce3d2d9131139b5b188d9cf90c64/packages/kit/src/core/config/index.js#L198-L219","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before (vite.config.js)\nimport customPlugin from 'not-installed-plugin';\nexport default { plugins: [customPlugin()] };\n\n// after\nexport default { plugins: [] }; // install the dependency or remove the import","handlingStrategy":"try-catch","validationCode":"node --input-type=module -e \"await import('./vite.config.js').then(() => console.log('config OK'))\"","typeGuard":null,"tryCatchPattern":"try {\n  const { svelteConfig } = await loadViteConfig();\n} catch (e) {\n  console.error('Vite config failed:', e.message); // real cause printed by SvelteKit above\n  process.exit(1);\n}","preventionTips":["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"],"tags":["config","vite","startup"],"backgroundTag":"vite-config-load-failed","analyzedSha":"03f1687fe612ce3d2d9131139b5b188d9cf90c64","analyzedAt":"2026-09-02T02:01:50.504Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-09T06:17:21.866Z"}