Skip to content
Latchkey

Vite "Internal server error" from PostCSS during build in CI

Vite runs CSS through PostCSS. A plugin that is not installed, a config that exports the wrong shape, or invalid CSS makes PostCSS throw, and Vite surfaces it as an internal server error or a build-time CSS failure.

What this error means

The build fails with a PostCSS message such as "Failed to load PostCSS config", "Cannot find module 'tailwindcss'", or "[postcss] ... Unexpected" pointing at a stylesheet.

vite
[vite:css] Failed to load PostCSS config (searchPath: /app): [Error]
Loading PostCSS Plugin failed: Cannot find module 'autoprefixer'
(@/app/postcss.config.js)

Common causes

A PostCSS plugin is not installed in CI

A plugin referenced in postcss.config was a devDependency the CI install skipped, so PostCSS cannot load it.

An invalid PostCSS config export

The config exports the wrong shape (for example ESM/CJS mismatch) or references a plugin by the wrong name.

How to fix it

Install the missing PostCSS plugins

  1. Read which module PostCSS could not load.
  2. Install it as a real dependency CI keeps.
  3. Re-run the build so PostCSS resolves every plugin.
Terminal
npm install -D autoprefixer tailwindcss postcss
npm ci

Fix the config export shape

Match the config module format to your project so Vite can load it (CommonJS shown).

postcss.config.cjs
// postcss.config.cjs
module.exports = { plugins: { autoprefixer: {} } };

How to prevent it

  • Install PostCSS plugins as dependencies the CI install retains.
  • Keep the config module format consistent with your project type.
  • Reference plugins by their exact package name.

Frequently asked questions

What causes ""Internal server error" (PostCSS)"?
A plugin referenced in postcss.config was a devDependency the CI install skipped, so PostCSS cannot load it.
How do I fix "Internal server error" (PostCSS)?
Install the missing PostCSS plugins

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card