facebook/docusaurus · error · Error

Docs option lastVersion: ${options.lastVersion} is invalid.

Error message

Docs option lastVersion: ${options.lastVersion} is invalid. ${availableVersionNamesMsg}

What it means

Thrown by validateVersionsOptions in the docs plugin when the 'lastVersion' option references a version name that does not exist among the available version names (derived from versioned_docs/versions.json plus the current version). lastVersion determines which version is served at the docs root route, so it must resolve to a real version. The message lists the valid names to make the mismatch obvious.

Source

Thrown at packages/docusaurus-plugin-content-docs/src/versions/validation.ts:73

/**
 * @throws Throws for one of the following invalid options:
 * - `lastVersion` is non-existent
 * - `versions` includes unknown keys
 * - `onlyIncludeVersions` is empty, contains unknown names, or doesn't include
 * `latestVersion` (if provided)
 */
export function validateVersionsOptions(
  availableVersionNames: string[],
  options: VersionsOptions,
): void {
  const availableVersionNamesMsg = `Available version names are: ${availableVersionNames.join(
    ', ',
  )}`;
  if (
    options.lastVersion &&
    !availableVersionNames.includes(options.lastVersion)
  ) {
    throw new Error(
      `Docs option lastVersion: ${options.lastVersion} is invalid. ${availableVersionNamesMsg}`,
    );
  }
  const unknownVersionConfigNames = _.difference(
    Object.keys(options.versions),
    availableVersionNames,
  );
  if (unknownVersionConfigNames.length > 0) {
    throw new Error(
      `Invalid docs option "versions": unknown versions (${unknownVersionConfigNames.join(
        ',',
      )}) found. ${availableVersionNamesMsg}`,
    );
  }

  if (options.onlyIncludeVersions) {
    if (options.onlyIncludeVersions.length === 0) {
      throw new Error(

View on GitHub (pinned to 3f483e80e3)

Solutions

  1. Read the error's 'Available version names are:' list and set lastVersion to one of those exact strings.
  2. Open versions.json and confirm the version names; fix lastVersion in docusaurus.config.js docs options to match.
  3. If you want the newest version served at root, you can often omit lastVersion entirely and let the plugin pick the latest.
  4. After editing, rebuild (pnpm start / build) to re-run validation.

Example fix

// before
docs: {
  lastVersion: '2.0', // but versions.json only has current, 1.0
}
// after
docs: {
  lastVersion: '1.0',
}
Defensive patterns

Strategy: validation

Validate before calling

import fs from 'fs';
const available = JSON.parse(fs.readFileSync('versions.json','utf8')); // string[]
const current = 'current';
const all = [...available, current];
if (config.lastVersion && !all.includes(config.lastVersion)) {
  throw new Error(`lastVersion ${config.lastVersion} not in ${all.join(', ')}`);
}

Type guard

const isKnownVersion = (v: string, available: string[]): boolean =>
  available.includes(v);

Prevention

When it happens

Trigger: Setting docs.lastVersion to a string that is not in the availableVersionNames array (e.g. lastVersion:'2.0' when only ['current','1.0'] exist, or a typo like 'curent'). Triggered during option validation at build/dev startup of plugin-content-docs.

Common situations: Renaming a version in versions.json without updating lastVersion; cutting a new version (docusaurus docs:version) and forgetting to point lastVersion at it; copy-pasting a config from another project whose version names differ; typos after a major version bump.

Related errors


AI-assisted analysis of facebook/docusaurus@3f483e80e3 (2026-08-12). Data as JSON: /api/errors/abbf0ead7e1dfe44. Report an issue: GitHub.