Could not auto-determine entry point from rollupOptions
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
The error Could not auto-determine entry point from rollupOptions occurs in Vite (which uses Rollup internally) when the build configuration does not specify an entry point and Vite cannot find a default index.html file in the project root. This typically happens when building a library without configuring build.lib, when the root directory is misconfigured, or when using Vite for a non-standard project structure. The fix is to explicitly set the entry point in build.rollupOptions.input or configure build.lib for library mode.
The Error
How Vite Determines the Entry Point
Vite's default behavior for finding the entry point:
- Look for
index.htmlin the project root (or the directory specified byroot) - Parse
index.htmlfor<script type="module" src="...">tags - Use those script sources as Rollup entry points
If no index.html exists or it does not contain a module script, Vite cannot determine the entry point.
Fix 1: Add index.html (Standard Vite App)
The <script type="module" src="/src/main.js"> tag tells Vite to use src/main.js as the entry point.
Fix 2: Specify rollupOptions.input (Custom Entry)
Multiple Entry Points (Multi-Page App)
Fix 3: Configure build.lib (Library Mode)
When building a library (not an application), use library mode instead of relying on index.html:
Fix 4: Set the root Option
If your index.html is not in the project root:
Fix 5: Pure Rollup Configuration
If you are using Rollup directly (not through Vite):
Common Project Structures
Single-Page App (SPA)
No extra configuration needed — Vite finds index.html in the root.
Library
Requires build.lib.entry in vite.config.js.
Monorepo Package
Common Pitfalls
- Missing
index.htmlin root directory: Vite requiresindex.htmlin the root (or therootoption directory) for application mode. If you moved it topublic/orsrc/, either move it back or setrootaccordingly. index.htmlwithout<script type="module">: Anindex.htmlthat only has regular<script>tags (nottype="module") does not provide Vite an entry point. Addtype="module"to your script tag.- Using
build.libandrollupOptions.inputsimultaneously: When both are specified, they can conflict. In library mode, usebuild.lib.entryfor the entry point.rollupOptions.inputis for application mode or overriding specific Rollup behavior. - Relative paths in
rollupOptions.input: Always useresolve(__dirname, 'path')for entry points. Relative paths resolve from the working directory, which may differ between development and CI environments. - Vite config in wrong location:
vite.config.jsmust be in the project root (next topackage.json). If it is in a subdirectory, Vite will not find it and uses defaults, which may not locate yourindex.html.
Summary
- Vite auto-detects entry points from
index.htmlin the project root — the error means it could not find one - For standard apps, ensure
index.htmlexists at the root with a<script type="module">tag - For libraries, configure
build.lib.entryinvite.config.js - For custom structures, set
rollupOptions.inputor therootoption - For multi-page apps, pass an object to
rollupOptions.inputwith named entries - Always use
resolve(__dirname, 'path')for absolute entry point paths

