tailwindlabs/tailwindcss · error · Error

Could not resolve '${id}' from '${base}'

Error message

Could not resolve '${id}' from '${base}'

What it means

`loadModule` resolves JavaScript module ids for `@plugin` / `@config` directives. When the id is a bare specifier (does not start with `.`), it is resolved via `resolveJsId` against `base`; if resolution returns nothing, the plugin/config package cannot be found. This mirrors Node's module-not-found semantics for plugin packages.

Source

Thrown at packages/@tailwindcss-node/src/compile.ts:127

    async loadModule(id, base) {
      return loadModule(id, base, () => {})
    },
    async loadStylesheet(id, base) {
      return loadStylesheet(id, base, () => {})
    },
  })
}

export async function loadModule(
  id: string,
  base: string,
  onDependency: (path: string) => void,
  customJsResolver?: Resolver,
) {
  if (id[0] !== '.') {
    let resolvedPath = await resolveJsId(id, base, customJsResolver)
    if (!resolvedPath) {
      throw new Error(`Could not resolve '${id}' from '${base}'`)
    }

    let module = await importModule(pathToFileURL(resolvedPath).href)
    return {
      path: resolvedPath,
      base: path.dirname(resolvedPath),
      module: module.default ?? module,
    }
  }

  let resolvedPath = await resolveJsId(id, base, customJsResolver)
  if (!resolvedPath) {
    throw new Error(`Could not resolve '${id}' from '${base}'`)
  }

  let [module, moduleDependencies] = await Promise.all([
    importModule(pathToFileURL(resolvedPath).href + '?id=' + Date.now()),
    getModuleDependencies(resolvedPath),

View on GitHub (pinned to 16e94cbf7f)

Solutions

  1. Install the missing package: `npm install <plugin-name>` (or the appropriate workspace install).
  2. Check the spelling and scoped name in the `@plugin`/`@config` directive against the package's published name.
  3. Verify the package is resolvable from the CSS file's base directory (run `node -e "require.resolve('<id>')"` from that folder).

Example fix

/* before */
@plugin "@tailwindcss/typograph";

# after
npm install @tailwindcss/typography
/* @plugin "@tailwindcss/typography"; */
Defensive patterns

Strategy: validation

Validate before calling

import { createRequire } from 'node:module'
function assertPluginResolvable(id: string, base: string) {
  if (id[0] === '.') return // handled by relative check
  try { createRequire(path.resolve(base, 'noop.js')).resolve(id) }
  catch { throw new Error(`Plugin '${id}' not installed; run: npm install ${id}`) }
}

Type guard

function isBareSpecifier(id: string): boolean { return id[0] !== '.' }

Try / catch

try {
  await loadModule(id, base, () => {})
} catch (e) {
  if (/Could not resolve/.test((e as Error).message) && id[0] !== '.') {
    console.error(`Install missing dependency: npm install ${id}`)
  }
  throw e
}

Prevention

When it happens

Trigger: `@plugin "@tailwindcss/typography"` when that package is not installed in `node_modules`, or a bare specifier with a typo. `id[0] !== '.'` is true, `resolveJsId` returns falsy, and compile.ts:127 throws.

Common situations: Missing `npm install` of a plugin package, monorepo where the plugin is hoisted to a workspace root not visible from `base`, or using a plugin that is only a devDependency in a different workspace.

Related errors


AI-assisted analysis of tailwindlabs/tailwindcss@16e94cbf7f (2026-08-12). Data as JSON: /api/errors/80dd29b4c94648f1. Report an issue: GitHub.