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.
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
- Install tailwindcss (and postcss, autoprefixer) as devDependencies.
- Commit the updated package.json and lockfile.
- Re-run the CSS build.
npm install --save-dev tailwindcss postcss autoprefixerVerify the lockfile carries it
Confirm the package appears in the committed lockfile so npm ci installs it deterministically in CI.
npm ciHow to prevent it
- Declare tailwindcss, postcss, and autoprefixer as devDependencies.
- Use
npm ciso the lockfile drives installs in CI. - Avoid relying on globally installed CSS tooling.