When I was installing postCSS on my react project I was getting the same error also, and I found this error because the postCSS is a edm only module and I figure out that I need to update the file extension vite config file .
I rename at it to vite.config.mjs from vite.config.js file and That is How My problem resolved.
and I restarted my react app and it work successfully