vitejs/vite · error · Error

Unsupported target "${entry}"

Error message

Unsupported target "${entry}"

What it means

Thrown by `convertTargets` when a target entry is not an `es*` version, not `esnext`, and does not map to a known browser. After stripping ES versions, each remaining entry is parsed for a browser+version; if the browser prefix is unknown or the version unparseable, the entry is rejected verbatim.

Source

Thrown at packages/vite/src/node/plugins/css.ts:3646

    const index = entry.search(versionRE)
    if (index >= 0) {
      const browser = map[entry.slice(0, index)]
      if (browser === false) continue // No mapping available
      if (browser) {
        const [major, minor = 0] = entry
          .slice(index)
          .split('.')
          .map((v) => parseInt(v, 10))
        if (!isNaN(major) && !isNaN(minor)) {
          const version = (major << 16) | (minor << 8)
          if (!targets[browser] || version < targets[browser]!) {
            targets[browser] = version
          }
          continue
        }
      }
    }
    throw new Error(`Unsupported target "${entry}"`)
  }

  convertTargetsCache.set(esbuildTarget, targets)
  return targets
}

export function resolveLibCssFilename(
  libOptions: LibraryOptions,
  root: string,
  packageCache?: PackageCache,
): string {
  if (typeof libOptions.cssFileName === 'string') {
    return `${libOptions.cssFileName}.css`
  } else if (typeof libOptions.fileName === 'string') {
    return `${libOptions.fileName}.css`
  }

  const packageJson = findNearestMainPackageData(root, packageCache)?.data

View on GitHub (pinned to 89620f09af)

Solutions

  1. Use a supported browser target format (e.g. `chrome100`, `firefox80`, `safari14`, `edge85`, `opera67`, `ios14`).
  2. Remove Node/Deno targets from the CSS/lightningcss target list — those are not browser targets.
  3. Set the target to `'esnext'` or a supported ES year to bypass browser mapping.
  4. Check the exact `entry` in the message and correct the spelling/format.

Example fix

// before
export default defineConfig({ build: { target: ['node18', 'chrome100'] } });
// after
export default defineConfig({ build: { target: ['chrome100'] } });
Defensive patterns

Strategy: validation

Validate before calling

const SUPPORTED_BROWSERS = new Set(['chrome','edge','safari','ios','firefox','opera']);

function validateBrowserTargets(target) {
  for (const t of [].concat(target)) {
    if (t === 'esnext') continue;
    const m = /^([a-z]+)(\d+)/.exec(t);
    if (m && !SUPPORTED_BROWSERS.has(m[1])) {
      throw new Error(`Unsupported browser target: ${t}`);
    }
  }
}
// validateBrowserTargets(config.build.target);

Type guard

function isSupportedBrowserTarget(t) {
  const m = /^([a-z]+)(\d+)/.exec(t);
  return !!m && new Set(['chrome','edge','safari','ios','firefox','opera']).has(m[1]);
}

Prevention

When it happens

Trigger: A target string like `node14`, `deno1`, `ie11`, or a typo (`chromium99`) reaches the final `throw` at line 3646 because `map[entry.slice(0,index)]` is undefined/false and version parsing falls through.

Common situations: Setting `build.target`/CSS target to Node, Deno, or a non-browser environment (lightningcss targets are browser-only); an unrecognized browser alias; a target list copy-pasted from a non-Vite config.

Related errors


AI-assisted analysis of vitejs/vite@89620f09af (2026-08-03). Data as JSON: /data/errors/8d6bd11a25bdb9f2.json. Report an issue: GitHub.