Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vite PostCSS module error when building app in Svelte

I came across this strange error in Svelte; every time I ran npm run dev, this vite error would appear:

[vite] Internal server error: Failed to load PostCSS config (searchPath: /Users/Documents/Personal projects): [Failed to load PostCSS config] Failed to load PostCSS config (searchPath: /Users/Documents/Personal projects): [Failed to load PostCSS config] Failed to load PostCSS config (searchPath: /Users/Documents/Personal projects): [Error] Cannot find module 'autoprefixer'

I'm new to vite so it took me an hour of research, to figure out how to export the module, I was able to fix it by creating a postcss.config.cjs file and inside the file add:

module.exports = {
    autoprefixer: {}
}

I hope this helps anyone that comes across the same/similar error.

like image 788
Silvinecoder Avatar asked May 08 '26 20:05

Silvinecoder


1 Answers

Create postcss.config.cjs file and add:

module.exports = {
    autoprefixer: {}
}

The reason why it wasn't building, is because svelte wasn't exporting the autoprefixer module

like image 85
Silvinecoder Avatar answered May 11 '26 14:05

Silvinecoder



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!