tailwindcss: Please give me details related to our code for "Unknown word" error.

After upgrading to Tailwind 4, I’m getting this error in my Qwik + Tailwind app:

x Build failed in 4.66s
error during build:
[vite:css] [postcss] /Project/SiteQwik/src/global.css:3444:27: Unknown word
file: /Project/SiteQwik/src/global.css:3444:26
    at Input.error (/npm/node_modules/postcss/lib/input.js:109:16)
    at Parser.unknownWord (/npm/node_modules/postcss/lib/parser.js:593:22)
    at Parser.other (/npm/node_modules/postcss/lib/parser.js:435:12)
    at Parser.parse (/npm/node_modules/postcss/lib/parser.js:470:16)
    at parse (/npm/node_modules/postcss/lib/parse.js:11:12)
    at new LazyResult (/npm/node_modules/postcss/lib/lazy-result.js:133:16)
    at Processor.process (/npm/node_modules/postcss/lib/processor.js:53:14)
    at compileCSS (file:///npm/node_modules/vite/dist/node/chunks/dep-CHZK6zbr.js:36898:59)
    at async Object.transform (file:///npm/node_modules/vite/dist/node/chunks/dep-CHZK6zbr.js:36171:11)
    at async transform (file:///npm/node_modules/rollup/dist/es/shared/node-entry.js:20698:16)

❌ Error: Client build failed: Error: Command failed with exit code 1: npm run build.client

node:internal/modules/cjs/loader:1247
  throw err;

The problem is that it does not tell us where. As a developer I need to know some info related to MY code in order to be able to track the problem and solve it.

Please give us some info related to our code in this error.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 16 (3 by maintainers)

Most upvoted comments

As a Nuxt3 user I started encountering this error once I upgrade to @nuxt/ui@3.0.0-beta.2, which includes the Tailwindcss 4.0.x release as a dependency.

My main.css has the following lines to embed the tailwindcss:

@import "tailwindcss" theme(static);
@import "@nuxt/ui";

This results in the following compilation error:

  ERROR  Internal server error: [postcss] /code/tangodata/try/layers/90_base/app/assets/css/tailwind.css:3133:27: Unknown word &quot
  Plugin: vite:css
  File: /code/tangodata/try/layers/90_base/app/assets/css/tailwind.css:3133:26
      at Input.error (/code/tangodata/try/node_modules/.pnpm/postcss@8.5.3/node_modules/postcss/lib/input.js:113:16)
      at Parser.unknownWord (/code/tangodata/try/node_modules/.pnpm/postcss@8.5.3/node_modules/postcss/lib/parser.js:595:22)

Following some issues discussion (https://github.com/nuxt/ui/issues/3374), it was suggested to change the main.css to the following form:

@layer theme, base, components, utilities;
@import 'tailwindcss/theme' layer(theme) theme(static);
@import 'tailwindcss/preflight' layer(base);
@import 'tailwindcss/utilities' layer(utilities);
@import '@nuxt/ui';

This also fails, but if the fourth line is commented out then no compilation error from postcss:

/* @import 'tailwindcss/utilities' layer(utilities); */

So I guess there is an error in the utilities layer that needs to be fixed.

@Nefcanto Mind sharing your Vite config? I suppose that something is converting " to " before Tailwind CSS sees the stylesheets. If you have more than one plugin in your Vite config, ensure tailwindcss() comes first.

Hey! There is likely something detected as an arbitrary candidate that produces invalid CSS. Unfortunately it seems like downstream tools like PostCSS will choke on that completely without giving you more information 😕

Since I see that you’re using Vite, you could try adding this Vite plugin to print the interim CSS and then send it to us so we can take a look at what the faulty line is? Definitely something we should handle better!

/* vite.config.ts */
import tailwindcss from '@tailwindcss/vite'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vite'

  export default defineConfig({
    plugins: [
      react(), 
      tailwindcss(), 
+     inspect(),
    ],
  })

+ function inspect() {
+   return {
+     name: 'vite-plugin-inspect',
+     enforce: 'pre',
+     transform(css, id) {
+       if (id.endsWith('.css')) {
+         console.log(css)
+       }
+     },
+   }
+ }