{"record":{"id":"9666f8b56c256065","repo":"anomalyco/sst","slug":"could-not-load-vite-configuration-from-file","errorCode":null,"errorMessage":"Could not load Vite configuration from \"${file}\". Check that your Remix project uses Vite and the file exists.","messagePattern":"Could not load Vite configuration from \"(.+?)\"\\. Check that your Remix project uses Vite and the file exists\\.","errorType":"exception","errorClass":"VisibleError","httpStatus":null,"severity":"error","filePath":"platform/src/components/aws/remix.ts","lineNumber":482,"sourceCode":"\n          try {\n            // @ts-ignore\n            const vite = await import(\"vite\");\n            const config = await vite.loadConfigFromFile(\n              { command: \"build\", mode: \"production\" },\n              path.join(outputPath, file),\n            );\n            if (!config) throw new Error();\n\n            return {\n              __remixPluginContext: {\n                remixConfig: {\n                  buildDirectory: buildDirectory ?? \"build\",\n                },\n              },\n            };\n          } catch (e) {\n            throw new VisibleError(\n              `Could not load Vite configuration from \"${file}\". Check that your Remix project uses Vite and the file exists.`,\n            );\n          }\n        }\n\n        function createServerLambdaBundle() {\n          // Create a Lambda@Edge handler for the Remix server bundle.\n          //\n          // Note: Remix does perform their own internal ESBuild process, but it\n          // doesn't bundle 3rd party dependencies by default. In the interest of\n          // keeping deployments seamless for users we will create a server bundle\n          // with all dependencies included. We will still need to consider how to\n          // address any need for external dependencies, although I think we should\n          // possibly consider this at a later date.\n\n          // In this path we are assuming that the Remix build only outputs the\n          // \"core server build\". We can safely assume this as we have guarded the\n          // remix.config.js to ensure it matches our expectations for the build","sourceCodeStart":464,"sourceCodeEnd":500,"githubUrl":"https://github.com/anomalyco/sst/blob/a0bd20f762883e72a35caccb4896c42ce5b3f707/platform/src/components/aws/remix.ts#L464-L500","documentation":"The Remix component auto-detects the project's Vite config file (vite.config.ts/js) to read build settings. When evaluating that file fails (via createServerRequire/import in loadViteConfig), SST throws this VisibleError rather than silently misconfiguring the deployment.","triggerScenarios":"Calling `new Remix(...)` (via viteConfig) where the resolved vite config file path is missing, contains a syntax error, throws at import time, or the project uses the classic Remix compiler without Vite.","commonSituations":"Remix app still on the non-Vite compiler; vite.config.ts uses imports/plugins that fail outside the project's Node/bun version; typo'd root path so the config file isn't found; TS decorators/syntax not transpiled when loaded.","solutions":["Add a valid vite.config.ts to your Remix app root (migrate the app to Remix Vite if it uses the classic compiler)","Fix the runtime error/syntax in vite.config.ts and run the config in isolation to verify it loads","Confirm the `path` argument to the Remix component points at the directory containing the Vite config","Check Node/bun version compatibility for plugins used in vite.config.ts"],"exampleFix":"// before (classic Remix project, no Vite)\n// (no vite.config.ts)\n// after\n// vite.config.ts\nimport { vitePlugin as remix } from \"@remix-run/dev\";\nimport { defineConfig } from \"vite\";\nexport default defineConfig({ plugins: [remix()] });","handlingStrategy":"validation","validationCode":"import fs from \"fs\";\nconst viteConfig = [\"vite.config.ts\", \"vite.config.js\", \"vite.config.mjs\"]\n  .map((f) => `${remixPath}/${f}`)\n  .find((p) => fs.existsSync(p));\nif (!viteConfig) throw new Error(\"vite.config.ts missing in Remix app\");\n// also: run `bun --print 'require(\"<path>\").default'`-style load test locally","typeGuard":"function hasViteConfig(dir: string): boolean {\n  return [\"ts\",\"js\",\"mjs\",\"cjs\"].some((ext) => fs.existsSync(`${dir}/vite.config.${ext}`));\n}","tryCatchPattern":"try {\n  const site = new Remix(ctx, \"Site\", { path: remixPath });\n} catch (e) {\n  if (String(e).includes(\"Could not load Vite configuration\")) {\n    console.error(\"Check vite.config.ts exists and loads\");\n  }\n  throw e;\n}","preventionTips":["Keep vite.config.ts free of top-level side effects and env-dependent throws","Migrate fully to the Remix Vite compiler","Run `vite build` in the app before `sst deploy` to validate the config"],"tags":["remix","vite","config","sst"],"backgroundTag":"config-file-load-failed","analyzedSha":"a0bd20f762883e72a35caccb4896c42ce5b3f707","analyzedAt":"2026-08-30T11:26:00.383Z","schemaVersion":2},"datasetVersion":"2026-08-30T13:17:10.514Z"}