Vibe Code Rescue

Build fails with "Cannot find module 'tailwindcss'" in your AI built app

Your app from v0, Bolt, Lovable, or Cursor runs fine in the tool, but npm run build fails with Error: Cannot find module 'tailwindcss', in Next.js apps often wrapped in "An error occurred in next/font" followed by "Build failed because of webpack errors". The fix is usually one install command; the interesting part is why it happens.

Why the AI left the dependency out

Your code uses Tailwind everywhere: the class names are all over your components, and the config files (tailwind.config.ts, postcss.config.js) exist. But tailwindcss itself is missing from package.json. This happens because AI generators assemble projects from templates and edits; somewhere along the way the package list got regenerated without every package the code actually needs. The tool's own sandbox often has these packages preinstalled globally, so the error never appears until you build on a clean machine, which is exactly what Vercel, Netlify, and your laptop are.

The next/font wrapper appears because in recent Next.js versions the font loader participates in the CSS pipeline, so it is the first thing to trip over the missing Tailwind and it gets blamed in the error message. The real culprit is the missing package, not your fonts.

I found this exact case in a clean-room build sweep of publicly available AI built apps: a launch page app whose build failed with this error on every fresh clone. One in 16 swept apps had it, and its owner had no way to see it inside the tool.

The fix

Install what the config expects. Check which Tailwind major version your project is written for:

npm install -D tailwindcss @tailwindcss/postcss
npm install -D tailwindcss@^3 postcss autoprefixer

Then run npm run build again. If a different "Cannot find module" appears next, repeat: the project may be missing several packages, and each build failure names the next one. Two or three rounds usually clears it.

If the versions fight back

Mixing v3-style config with the v4 package (or the reverse) produces confusing errors like "trying to use tailwindcss directly as a PostCSS plugin". Match the package major version to the config style the AI wrote, do not modernize the config mid-rescue. Get the build green first, upgrade later if you want.

Build passes but the page is unstyled or blank?

Different failure class. Unstyled usually means the Tailwind content globs do not match your file layout. Blank white screen usually means a runtime crash before React mounts, most often missing environment variables: see the blank screen guide.

Still stuck?

Run the instant diagnosis. Paste your public repo URL into the form and an automated clean-room check installs and builds your app, then posts a plain English report naming exactly what is missing, in minutes, free. Build failures like this one are precisely what it catches. Private repo or zip? Email works too.

Get an instant free diagnosis

Or email me instead. Fixes with 24 hour turnaround start at $95. Prefer self-serve? The $5 instant diagnosis on Apify checks your repo privately, no public issue needed.