Skip to content

Build fails with "Could not find server config output file" when Vite outputs .mjs files - workaround included #1927

@weepotty

Description

@weepotty

Production builds fail during the prerendering step when Vite outputs ES module files with .mjs extensions instead of .js.

Error:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/path/to/dist/server/entry.server.js'
❌ Build failed: Could not find server config output file

Root Cause
Two files have hardcoded .js extensions:
dist/config/loader.js:58 - looks for zudoku.config.js
dist/vite/prerender/prerender.js:19 - looks for entry.server.js
But Vite outputs .mjs files, causing the lookups to fail.

Environment
Zudoku: 0.67.0
Vite: 6.4.1
Yarn: 4.9.4
Node: 22.12.0

Reproduction
Use Zudoku with default Vite configuration
Run yarn build
Build fails during prerendering step

Suggested Fix:
// loader.js line 58

const result = output.output.find((o) => 
  "isEntry" in o && o.isEntry && 
  (o.fileName === "zudoku.config.js" || o.fileName === "zudoku.config.mjs")
);

// prerender.js line 19

const entryServerMjs = path.join(distDir, "server/entry.server.mjs");
const entryServerJs = path.join(distDir, "server/entry.server.js");
const entryServerExists = await fileExists(entryServerMjs);
const entryServerPath = pathToFileURL(entryServerExists ? entryServerMjs : entryServerJs).href;

Workaround used
For Yarn 4+ users, you can create a patch:

  1. Run yarn patch zudoku
  2. Apply the fixes shown in the "Suggested Fix" section above
  3. Run yarn patch-commit -s /path/from/yarn/output

This will generate a patch file that automatically applies on yarn install.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions