vercel/next.js · error · Error

AI upgrades are not available for prerelease versions of…

Error message

AI upgrades are not available for prerelease versions of Next.js yet.

What it means

AI-assisted upgrades are only implemented for stable releases. If the app's installed Next.js version has a prerelease tag (canary, rc, beta, alpha), prepareUpgrade refuses to run because codemod targets and advisory ranges are not defined against moving prerelease channels yet.

Solutions

  1. Switch the app to a stable release: npm i next@latest (plus matching react/react-dom), then rerun the upgrade
  2. Pin a stable version in package.json instead of a canary tag/dist-tag
  3. If you must stay on canary, upgrade manually with npx @next/codemod@canary upgrade instead of --ai

Example fix

// before
"next": "canary"
// after
"next": "15.3.0"
Defensive patterns

Strategy: validation

Validate before calling

const semver = require('semver')
const v = require('next/package.json').version
if (semver.prerelease(v)) {
  console.error('AI upgrade requires a stable next release; current:', v)
}

Try / catch

try {
  await prepareUpgrade(dir, 'latest')
} catch (e) {
  if (e.message.includes('prerelease')) {
    // switch to next@latest or use manual @next/codemod upgrade
  }
}

Prevention

When it happens

Trigger: Running `next upgrade --ai` in an app whose package.json uses next@canary, next@rc, or a local build with a prerelease version suffix.

Common situations: Apps tracking canary for new features; contributors testing against next rc builds; monorepos where one workspace pins canary.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of vercel/next.js@34433fd12e (2026-09-20). Data as JSON: /api/errors/54382f147ae754f7. Report an issue: GitHub.

Appendix: source

Thrown at packages/next/src/lib/upgrade/prepare-upgrade.ts:49

    )
  }

  // Resolve from the app: the invoking canary is only the upgrade tooling.
  const requireFromApp = createRequire(join(directory, 'package.json'))
  const installedNext = JSON.parse(
    await readFile(requireFromApp.resolve('next/package.json'), 'utf8')
  ) as {
    version: string
  }
  const installedVersion = installedNext.version

  if (!semver.valid(installedVersion)) {
    throw new Error('Could not determine the installed Next.js version.')
  }

  // TODO: Handle prereleases
  if (semver.prerelease(installedVersion)) {
    throw new Error(
      'AI upgrades are not available for prerelease versions of Next.js yet.'
    )
  }

  if (targetRequest === 'latest' || targetRequest === 'future') {
    const url = `${NPM_REGISTRY}next/latest`
    const { value } = await fetchJSON(url)
    const release = value as { version: string } | null

    if (
      !release ||
      !semver.valid(release.version) ||
      semver.prerelease(release.version)
    ) {
      throw new Error('Could not determine the latest stable Next.js version.')
    }

    const targetVersion =

View on GitHub (pinned to 34433fd12e)