Where Does Vite Store Its Cache?
Vite caches pre-bundled dependencies in node_modules/.vite. What lives there, when to delete it, and the cacheDir option.
Last updated
Vite pre-bundles your dependencies with esbuild and stashes the result in node_modules/.vite. That folder is why the second dev-server start feels instant. Everything inside is regenerable, so deleting it is always safe and often the first fix for stale-dependency weirdness.
The location comes from the cacheDir option, defaulting to node_modules/.vite, or plain .vite when no package.json exists. Accept an absolute path or one relative to the project root. Run with --force to rebuild once without deleting by hand.
Where Vite stores this, by platform
node_modules\.vite
Inside the project root. Delete the folder or restart with --force when optimized deps look stale. Custom spots go in vite.config through the cacheDir key.
node_modules/.vite
Same project-relative role. Case-only renames of dependencies are the classic reason this cache lies to you. Wipe it and restart the dev server.
node_modules/.vite
Mirrors macOS exactly. Since it lives under node_modules, a fresh install already clears it. Keep it out of Docker layers you want to stay lean.
Frequently asked questions
Vite serves stale dependencies, what do I delete?
Remove node_modules/.vite and restart the dev server, or run vite --force once. That forces esbuild to re-optimize every dependency. If the ghost persists, the lockfile probably pins an old version.
How do I move the Vite cache elsewhere?
Set cacheDir in your Vite config to an absolute path or one relative to the project root. Useful for RAM-disk speedups or dodgy network filesystems. Remember to ignore the new spot wherever the old one was ignored.
Notice an outdated path? Let us know.