In my case the same error was caused by a usage of a different version of node.
I switched to node 20, initialized my project with npm create vite
, switched to node 16, and the error occurred on npm run dev
.
Just needed to switch back to the node version the project was initialized with.