As someone mentioned, what worked for me was to install compatible versions of vite and vitest. When I typed the npm ls vite
command, I realized there were different versions of vite, so I installed the specific version that vitest installed and I no longer get the error. If this is not a good solution, please let me know.