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.
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
- Confirm where
index.htmllives in the repo. - Run the build from that directory, or pass
--rootto point at it. - For library builds, set
build.rollupOptions.inputto the real entry.
npx vite build --root packages/webSet the input explicitly in config
Pin the entry so it does not depend on the current directory.
export default {
build: { rollupOptions: { input: 'src/main.ts' } }
}How to prevent it
- Set
working-directoryon the build step in a monorepo. - Commit the entry HTML or generate it before
vite buildruns. - Pin
rootandinputin config rather than relying on cwd.