Fixing Vite Build Error: Could Not Resolve Entry Module index.html
When a Vite build stops with Could not resolve entry module "index.html". (Vite 7) or [UNRESOLVED_ENTRY] Cannot resolve entry module index.html. (Vite 8), it is because there is no index.html directly in the project root (usually the folder where you run the build). Put index.html back directly in the project root (the same folder as package.json), or run the build from the project folder, and the error goes away.
This covers the cause and fix when npm run build fails without creating dist. In my test environment, I moved index.html to a different location to trigger this error, and I include the messages exactly as they were printed.
The test environment was Ubuntu 24.04, Node.js 22.23.5, Vite 8.3.8, @vitejs/plugin-react 6.3.0, React 19.3.1, and TypeScript 7.0.2. I created the project with the react-ts template from npm create vite@latest and placed it in a folder named /path/to/app. For the Vite 7 message, I copied the same template to /path/to/app7, then switched it to Vite 7.3.8 and @vitejs/plugin-react 5.2.0 to check. I have not tested on Windows, macOS, or other templates.
Error message when index.html is moved into src
In the react-ts template, index.html is directly in the project root. I moved it into src and then ran the build.
$ mv index.html src/
$ npx vite build
With Vite 8.3.8, the build stopped with the following message. The exit code was 1, and no dist folder was created. I omitted the final stack trace (from the at lines through the closing }).
vite v8.3.8 building client environment for production...
✓ 0 modules transformed.
transforming...
✗ Build failed in 14ms
error during build:
Build failed with 1 error:
[UNRESOLVED_ENTRY] Cannot resolve entry module index.html.
The template's npm run build (tsc -b && vite build) produced the same message. tsc -b passed without errors, and the build stopped in vite build afterward.
With Vite 7.3.8, the same mistake produced the following message. The exit code was also 1. I omitted the at lines of the stack trace.
vite v7.3.8 building client environment for production...
✓ 0 modules transformed.
✗ Build failed in 10ms
error during build:
Could not resolve entry module "index.html".
The wording differs, with Could not resolve in Vite 7 and Cannot resolve in Vite 8, but both mean the same thing: the index.html that serves as the build entry point cannot be found. As described in the migration guide from Vite 7, Vite 8 uses Rolldown instead of Rollup for builds. The difference in the message comes from that switch. The stack traces also showed rollup files for Vite 7 and rolldown files for Vite 8.
With index.html moved into src, the dev server (./node_modules/.bin/vite --port 5173 --strictPort) started without errors, but http://localhost:5173/ returned 404 and the page was blank. The terminal showed only the startup message and no error. The error message appears only during the build.
Where Vite looks for index.html
Vite treats index.html as the entry point of the app. The official guide's section on index.html and the project root states that keeping index.html directly in the project root, not inside public, is intentional.
The project root is set by the root option. If you don't set it, the default is process.cwd(), which is the folder where you run the command (root option). vite build looks for index.html directly in this folder. It does not find one inside src.

Moving index.html back to the project root fixes the error
I moved the index.html in src back to its original location.
$ mv src/index.html .
$ npx vite build
This time the build ran to completion and created dist/index.html. The exit code was 0.
vite v8.3.8 building client environment for production...
transforming...
✓ 20 modules transformed.
rendering chunks...
computing gzip size...
dist/index.html 0.45 kB │ gzip: 0.29 kB
dist/assets/react-CHdo91hT.svg 4.12 kB │ gzip: 2.06 kB
dist/assets/vite-BF8QNONU.svg 8.70 kB │ gzip: 1.60 kB
dist/assets/hero-CLDdwZDr.png 13.05 kB
dist/assets/index-D64VDMd1.css 4.10 kB │ gzip: 1.47 kB
dist/assets/index-GpEN3EET.js 222.44 kB │ gzip: 69.28 kB
✓ built in 129ms
npm run build also completed. I also confirmed with Vite 7.3.8 that the build finishes once index.html is moved back.
The same error occurs when running outside the project
Even with index.html in the correct place, running vite build from a different folder causes the same error. I ran the Vite installed in the project (app) from the folder one level above it.
$ ls
app
app7
$ ./app/node_modules/.bin/vite build
The result was the same [UNRESOLVED_ENTRY] Cannot resolve entry module index.html. as when index.html was in src, and the exit code was 1. The folder where the command runs becomes the root, and there is no index.html directly in it.
The simplest approach is to cd into the project folder before running the build. If you don't want to cd, you can pass the folder to use as the root as an argument. The vite build section of the CLI reference documents this as vite build [root].
$ ./app/node_modules/.bin/vite build app
Doing this, the build ran to completion and created app/dist/index.html. The names and sizes of the output files were the same as when I ran the command inside app.
Keeping index.html in src
You can also specify the HTML entry point with the input option. According to the input section for Vite 8, this value is written as a path relative to the root, and it also becomes the default for the build entry (build.rolldownOptions.input).
// vite.config.ts
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'
// https://vite.dev/config/
export default defineConfig({
plugins: [react()],
input: 'src/index.html',
})
With this config, the build left index.html in src and finished without errors. However, the generated HTML was written to dist/src/index.html rather than dist/index.html. In the dev server, http://localhost:5173/ returned 404, while http://localhost:5173/src/ returned 200.
The multi-page app section also explains that the HTML output keeps its path relative to the root. With this config, no index.html is created directly in dist. Unless you have a specific reason, it is simpler to put index.html back directly in the project root.





