Bottom Line: It is 100% safe to delete the node_modules/.vite folder. Deleting it will not affect your web application source code or installed npm packages.
What is the node_modules/.vite Folder?
Located inside JavaScript and TypeScript projects at node_modules/.vite, this folder is created by the Vite build tool / dev server (used by Vue, React, Svelte, and Astro).
When you run npm run dev or vite, Vite pre-bundles your node_modules dependencies into native ES modules (ESM) using esbuild and saves them in .vite. This gives Vite its near-instant dev server startup times.
Over time, as dependency packages change, stale pre-bundled chunks accumulate inside .vite.
Can You Delete node_modules/.vite?
✅ Yes, it is completely safe to delete.
- No source code risk: Your
src/files,package.json, and assets remain untouched. - Fixes HMR & import bugs: Deleting
.viteis the official fix when Vite’s Hot Module Replacement (HMR) gets stuck or throwsFailed to resolve importerrors. - Auto-regenerated: Vite will automatically recreate
.vitethe next time you start the dev server (vite --force).
How to Safely Clean Up Vite Cache
Method 1: Force Vite Dev Server Re-bundle (Recommended)
Run your dev server with the --force flag:
npx vite --force
Method 2: Manual Cache Deletion
Delete the .vite directory directly:
# macOS / Linux
rm -rf node_modules/.vite
# Windows (Command Prompt)
rmdir /s /q node_modules\.vite
# Windows (PowerShell)
Remove-Item -Recurse -Force node_modules/.vite
Related Guides
- Learn about deleting node_modules folders.
- How to clean up Next.js cache.
- Check if you can clean npm cache.
Discussion
Loading authentication...