Vite stops at startup while crawling your files for dependencies
Fix it fast
Most common cause, 1 of 4A source file reached by the crawl does not parse
Repair the code at that position, for example a leftover merge marker, an unclosed bracket or an import line typed only halfway.
npx vite --forceShort answer
Vite 7 and 8 print Failed to scan for dependencies from entries when the pre-bundle crawl reaches a file it cannot parse; the parser error that names the file and line follows the entry list. Fix that code. JSX inside a .js file needs a .jsx name, and stray HTML pages need optimizeDeps.entries set to the real entry.
Which cause do you have?
Start the dev server again with the pre-bundle cache ignored and the deps debug log switched on. The log shows each entry the crawl begins from, and the lines after the entry list name the file and position that could not be parsed.
npx vite --force --debug depsThen find the line you see in this list and open its fix:
- 1A source file reached by the crawl does not parse
Below the entry list: a parse error with a path inside src and a line number - 2JSX is written inside a file that ends in .js
The JSX syntax extension is not currently enabled (Vite 7, where esbuild runs the crawl) - 3The crawl includes HTML pages that are not part of the app
The entry list names .html files from places like a docs folder, a copied template or an old output folder - 4A Vue or Svelte script block holds TypeScript but has no lang attribute
The parse error points at a .vue or .svelte file, with ?id= and a number after the file name
What does the error look like?
Failed to scan for dependencies from entries:The JSX syntax extension is not currently enabledThe esbuild loader for this file is currently set to "js" but it must be set to "jsx" to be able to parse JSX syntax.
Cause 1 of 4
A source file reached by the crawl does not parse
You seeBelow the entry list: a parse error with a path inside src and a line number
Check
Failed to scan for dependencies from entries is a header Vite puts in front of the parser error from a file the crawl reached, so the useful part is what comes after the list of entries. Filter the output down to that part and open the file it points at.
npx vite --force 2>&1 | grep -A 12 "Failed to scan"Fix
Repair the code at that position, for example a leftover merge marker, an unclosed bracket or an import line typed only halfway. Start Vite again after each repair, because a second file may fail once the first one parses.
npx vite --forceVerify
The server prints its local URL, and with the deps log on the crawl ends with a line that reports the scan as completed and lists what it found.
npx vite --debug depsConfirmed by github.com
Cause 2 of 4
JSX is written inside a file that ends in .js
You seeThe JSX syntax extension is not currently enabled (Vite 7, where esbuild runs the crawl)
Check
On Vite 7 the scan fails with The JSX syntax extension is not currently enabled when JSX sits in a .js file, because the crawl runs through esbuild, whose .js loader reads plain JavaScript only. Vite handles JSX in .jsx and .tsx files without setup. List .js files under src that contain component tags.
grep -rlE "<[A-Z][A-Za-z]*[ />]" src --include=*.jsFix
Give every file that holds JSX the .jsx extension, then update the imports and the script tag in index.html that still name the old file. No config change is needed after that.
git mv src/main.js src/main.jsx
git mv src/App.js src/App.jsx
# index.html: <script type="module" src="/src/main.jsx"></script>Verify
Start the server with --force once more. The JSX message no longer appears, and the page loads.
npx vite --forceConfirmed by esbuild.github.io
Cause 3 of 4
The crawl includes HTML pages that are not part of the app
You seeThe entry list names .html files from places like a docs folder, a copied template or an old output folder
Check
The scan can also fail inside an HTML page that is not part of your app, because without optimizeDeps.entries Vite globs every .html file under the project root. Only node_modules, the current build.outDir, __tests__ and coverage are left out, so an old build folder with another name or a static demo page with a module script is crawled too.
find . -name "*.html" -not -path "*/node_modules/*"Fix
Name the real entry points yourself. The patterns are globs relative to the project root, and once they are set Vite stops searching for HTML files on its own. Deleting the leftover folder also works.
// vite.config.js
import { defineConfig } from 'vite'
export default defineConfig({
optimizeDeps: {
entries: ['index.html'],
},
})Verify
Run with the deps log again. The entry list now holds only what you configured.
npx vite --force --debug depsConfirmed by vite.dev
Cause 4 of 4
A Vue or Svelte script block holds TypeScript but has no lang attribute
You seeThe parse error points at a .vue or .svelte file, with ?id= and a number after the file name
Check
In Vue and Svelte projects the scan fails on a script block that holds TypeScript but has no lang="ts", because the scanner picks the parser for each block from that attribute and reads the rest as JavaScript. Look for script tags that lack the attribute.
grep -rn "<script" src --include=*.vue --include=*.svelte | grep -v "lang="Fix
Add lang="ts" to every script block that uses TypeScript syntax, or take the type annotations out of blocks that are meant to stay JavaScript.
<script setup lang="ts">
const count: number = 0
</script>Verify
Restart with --force and confirm the component renders.
npx vite --forceConfirmed by github.com
How do I stop it coming back?
- Name every React component file .jsx or .tsx from the first commit.
- Set optimizeDeps.entries to ['index.html'] in repositories that also hold docs, demos or old build folders.
- Run npx vite build in CI on each pull request, so a file that does not parse fails there before anyone pulls it.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.