If you are using Yarn of recent versions (such as Berry), the modules are most likely located in a shared cache and Vite can't link them properly.
It is enough to place a .yarnrc.yml
file in the root folder of the project, with just one line:
nodeLinker: node-modules
and run yarn install
again