Skip to content
Latchkey

Vite "Could not resolve entry module" build error in CI

Vite hands Rollup an entry point (by default index.html at the project root) and Rollup cannot find a file there. The build aborts before bundling anything.

What this error means

vite build fails immediately with "Could not resolve entry module \"index.html\"" or a custom input path. The same command works locally where the file is present.

vite
error during build:
RollupError: Could not resolve entry module "index.html".
    at error (file:///app/node_modules/rollup/dist/es/shared/parseAst.js)

Common causes

The build runs from the wrong directory

In a monorepo or with a custom root, the step runs vite build outside the folder that holds index.html, so the entry is missing.

The entry file is not committed

A generated or git-ignored index.html exists locally but is never produced on the clean runner checkout.

How to fix it

Build from the project root or set root explicitly

  1. Confirm where index.html lives in the repo.
  2. Run the build from that directory, or pass --root to point at it.
  3. For library builds, set build.rollupOptions.input to the real entry.
Terminal
npx vite build --root packages/web

Set the input explicitly in config

Pin the entry so it does not depend on the current directory.

vite.config.js
export default {
  build: { rollupOptions: { input: 'src/main.ts' } }
}

How to prevent it

  • Set working-directory on the build step in a monorepo.
  • Commit the entry HTML or generate it before vite build runs.
  • Pin root and input in config rather than relying on cwd.

Frequently asked questions

What causes ""Could not resolve entry module""?
In a monorepo or with a custom root, the step runs vite build outside the folder that holds index.html, so the entry is missing.
How do I fix "Could not resolve entry module"?
Build from the project root or set root explicitly

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card