Lockfile persistence after a package.json version rollback in Vite
0 reputation · 07 Aug 2026, 01:16 UTC
When a dependency version is changed in package.json and later rolled back to a previous version, Vite’s dependency pre‑bundling lockfile (node_modules/.vite/deps) may retain the entry for the newer version if the file already exists and optimizeDeps.force is not set.
This can leave the dev server serving bundles built against the newer dependency while the application code expects the older API, producing hard‑to‑debug runtime errors after a rollback. The Vite team has not yet decided on an automatic invalidation policy, leaving the behavior as an open design decision.
What should be the default lockfile invalidation strategy when a package.json version change is detected? Should Vite provide a configuration flag to automatically delete or rebuild the lockfile on version change, or rely on explicit workflow steps?