anomalyco/sst · error · VisibleError

Could not load Vite configuration from "${file}". Check that

Error message

Could not load Vite configuration from "${file}". Check that your Remix project uses Vite and the file exists.

What it means

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.

Source

Thrown at platform/src/components/aws/remix.ts:482

          try {
            // @ts-ignore
            const vite = await import("vite");
            const config = await vite.loadConfigFromFile(
              { command: "build", mode: "production" },
              path.join(outputPath, file),
            );
            if (!config) throw new Error();

            return {
              __remixPluginContext: {
                remixConfig: {
                  buildDirectory: buildDirectory ?? "build",
                },
              },
            };
          } catch (e) {
            throw new VisibleError(
              `Could not load Vite configuration from "${file}". Check that your Remix project uses Vite and the file exists.`,
            );
          }
        }

        function createServerLambdaBundle() {
          // Create a Lambda@Edge handler for the Remix server bundle.
          //
          // Note: Remix does perform their own internal ESBuild process, but it
          // doesn't bundle 3rd party dependencies by default. In the interest of
          // keeping deployments seamless for users we will create a server bundle
          // with all dependencies included. We will still need to consider how to
          // address any need for external dependencies, although I think we should
          // possibly consider this at a later date.

          // In this path we are assuming that the Remix build only outputs the
          // "core server build". We can safely assume this as we have guarded the
          // remix.config.js to ensure it matches our expectations for the build

View on GitHub (pinned to a0bd20f762)

Solutions

  1. Add a valid vite.config.ts to your Remix app root (migrate the app to Remix Vite if it uses the classic compiler)
  2. Fix the runtime error/syntax in vite.config.ts and run the config in isolation to verify it loads
  3. Confirm the `path` argument to the Remix component points at the directory containing the Vite config
  4. Check Node/bun version compatibility for plugins used in vite.config.ts

Example fix

// before (classic Remix project, no Vite)
// (no vite.config.ts)
// after
// vite.config.ts
import { vitePlugin as remix } from "@remix-run/dev";
import { defineConfig } from "vite";
export default defineConfig({ plugins: [remix()] });
Defensive patterns

Strategy: validation

Validate before calling

import fs from "fs";
const viteConfig = ["vite.config.ts", "vite.config.js", "vite.config.mjs"]
  .map((f) => `${remixPath}/${f}`)
  .find((p) => fs.existsSync(p));
if (!viteConfig) throw new Error("vite.config.ts missing in Remix app");
// also: run `bun --print 'require("<path>").default'`-style load test locally

Type guard

function hasViteConfig(dir: string): boolean {
  return ["ts","js","mjs","cjs"].some((ext) => fs.existsSync(`${dir}/vite.config.${ext}`));
}

Try / catch

try {
  const site = new Remix(ctx, "Site", { path: remixPath });
} catch (e) {
  if (String(e).includes("Could not load Vite configuration")) {
    console.error("Check vite.config.ts exists and loads");
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of anomalyco/sst@a0bd20f762 (2026-08-30). Data as JSON: /api/errors/9666f8b56c256065. Report an issue: GitHub.