Did you try installing vite as a dev dependency?
You can do so like this
npm install --save-dev vite
Then try running your code again. If you are still getting the same error after instally maybe check if your node-modules folder isn't missing. You can fresh install with:
rm -rf node_modules
npm install