{"record":{"id":"362dd37e03084c9b","repo":"tailwindlabs/tailwindcss","slug":"cannot-find-any-css-files-that-reference-tailwind","errorCode":null,"errorMessage":"Cannot find any CSS files that reference Tailwind CSS.\nBefore your project can be upgraded you need to create a CSS file that imports Tailwind CSS or uses ${highlight('@tailwind')}.","messagePattern":"Cannot find any CSS files that reference Tailwind CSS\\.\nBefore your project can be upgraded you need to create a CSS file that imports Tailwind CSS or uses (.+?)\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@tailwindcss-upgrade/src/codemods/css/link.ts","lineNumber":15,"sourceCode":"import { normalizePath } from '@tailwindcss/node'\nimport path from 'node:path'\nimport postcss from 'postcss'\nimport { DefaultMap } from '../../../../tailwindcss/src/utils/default-map'\nimport { Stylesheet } from '../../stylesheet'\nimport { error, highlight, relative, success } from '../../utils/renderer'\nimport { detectConfigPath } from '../template/prepare-config'\n\nexport async function linkConfigs(\n  stylesheets: Stylesheet[],\n  { configPath, base }: { configPath: string | null; base: string },\n) {\n  let rootStylesheets = stylesheets.filter((sheet) => sheet.isTailwindRoot)\n  if (rootStylesheets.length === 0) {\n    throw new Error(\n      `Cannot find any CSS files that reference Tailwind CSS.\\nBefore your project can be upgraded you need to create a CSS file that imports Tailwind CSS or uses ${highlight('@tailwind')}.`,\n    )\n  }\n  let withoutAtConfig = rootStylesheets.filter((sheet) => {\n    let hasConfig = false\n    sheet.root.walkAtRules('config', (node) => {\n      let configPath = path.resolve(path.dirname(sheet.file!), node.params.slice(1, -1))\n      sheet.linkedConfigPath = configPath\n      hasConfig = true\n      return false\n    })\n    return !hasConfig\n  })\n\n  // All stylesheets have a `@config` directives\n  if (withoutAtConfig.length === 0) return\n\n  // Find the config file path for each stylesheet","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/tailwindlabs/tailwindcss/blob/16e94cbf7f965c5ad697e90e940b5e178efad67c/packages/@tailwindcss-upgrade/src/codemods/css/link.ts#L1-L33","documentation":"The upgrade tool's `linkConfigs` step needs at least one CSS file that references Tailwind (a \"root stylesheet\") to attach the migrated config to. It detects root stylesheets by `isTailwindRoot` (presence of an `@import \"tailwindcss…\"` or `@tailwind` directive). If none are found, there is nothing to link a config to and the upgrade cannot proceed.","triggerScenarios":"Running `@tailwindcss/upgrade` in a project whose CSS files have no `@tailwind base; @tailwind components; @tailwind utilities;` and no `@import \"tailwindcss\"`. link.ts:15 throws when `rootStylesheets.length === 0`.","commonSituations":"Projects that inject Tailwind purely via JS (`import 'tailwindcss/base'`), or where the main CSS is generated/hidden, or fresh projects where the entry CSS was never created.","solutions":["Create a CSS entry file (e.g. `src/styles.css`) containing `@import \"tailwindcss\";` (v4) or the v3 `@tailwind` directives, then re-run the upgrade.","If upgrading from v3, ensure the existing `@tailwind base/components/utilities` directives are present in a discoverable `.css` file.","Point the upgrade tool at the correct CSS entry if it lives in a non-default location."],"exampleFix":"/* before: no CSS file references Tailwind */\n\n/* after: create src/styles.css */\n@import \"tailwindcss\";","handlingStrategy":"validation","validationCode":"import { readFileSync, existsSync } from 'node:fs'\nfunction assertHasTailwindRoot(cssFiles: string[]) {\n  const hasRoot = cssFiles.some(f => {\n    if (!existsSync(f)) return false\n    const css = readFileSync(f, 'utf8')\n    return /@import\\s+[\"']tailwindcss/.test(css) || /@tailwind\\s+(base|components|utilities)/.test(css)\n  })\n  if (!hasRoot) throw new Error('Create a CSS file with @import \"tailwindcss\" before upgrading')\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Create src/styles.css with @import \"tailwindcss\" before running upgrade.","Ensure v3 projects keep their @tailwind directives in a discoverable .css file.","Avoid Tailwind-via-JS-only setups that the upgrade cannot introspect."],"tags":["upgrade","stylesheet-detection","setup"],"backgroundTag":null,"analyzedSha":"16e94cbf7f965c5ad697e90e940b5e178efad67c","analyzedAt":"2026-08-12T06:02:42.469Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}