Having the same issue when using yarn v4, and solved by clearing browser cache, as described in the Vite doc:
Caching
File System Cache
Vite caches the pre-bundled dependencies in
node_modules/.vite. It determines whether it needs to re-run the pre-bundling step based on a few sources:...
If for some reason you want to force Vite to re-bundle deps, you can either start the dev server with the
--forcecommand line option, or manually delete thenode_modules/.vitecache directory.Browser Cache
Resolved dependency requests are strongly cached with HTTP headers
max-age=31536000,immutableto improve page reload performance during dev. Once cached, these requests will never hit the dev server again. They are auto invalidated by the appended version query if a different version is installed (as reflected in your package manager lockfile). If you want to debug your dependencies by making local edits, you can:
- Temporarily disable cache via the Network tab of your browser devtools;
- Restart Vite dev server with the
--forceflag to re-bundle the deps;- Reload the page.
In my case I had to delete the browser data folder, restart browser, then rerun app using vite --force. Clearing site data and doing a hard refresh did not work for me.