Skip to content
Latchkey

Tailwind "Cannot find module 'tailwindcss'" in CI

PostCSS tried to load the tailwindcss plugin named in postcss.config.js and Node could not resolve it. The package is missing from the installed dependencies in CI.

What this error means

The CSS build fails with "Error: Cannot find module 'tailwindcss'" originating from the PostCSS config that lists it as a plugin.

tailwind
Error: Cannot find module 'tailwindcss'
Require stack:
- /home/runner/work/app/app/postcss.config.js
    at Function._resolveFilename (node:internal/modules/cjs/loader)

Common causes

tailwindcss is not in package.json

The package was installed locally but never recorded as a dependency, so a clean CI install does not fetch it.

It was installed as a global, not a project dependency

A global tailwindcss is not on the project resolution path in CI, so the PostCSS plugin lookup fails.

How to fix it

Add tailwindcss to devDependencies

  1. Install tailwindcss (and postcss, autoprefixer) as devDependencies.
  2. Commit the updated package.json and lockfile.
  3. Re-run the CSS build.
Terminal
npm install --save-dev tailwindcss postcss autoprefixer

Verify the lockfile carries it

Confirm the package appears in the committed lockfile so npm ci installs it deterministically in CI.

Terminal
npm ci

How to prevent it

  • Declare tailwindcss, postcss, and autoprefixer as devDependencies.
  • Use npm ci so the lockfile drives installs in CI.
  • Avoid relying on globally installed CSS tooling.

Frequently asked questions

What causes ""Cannot find module 'tailwindcss'""?
The package was installed locally but never recorded as a dependency, so a clean CI install does not fetch it.
How do I fix "Cannot find module 'tailwindcss'"?
Add tailwindcss to devDependencies

Related guides

References

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