{"record":{"id":"54382f147ae754f7","repo":"vercel/next.js","slug":"ai-upgrades-are-not-available-for-prerelease-versions-of","errorCode":null,"errorMessage":"AI upgrades are not available for prerelease versions of Next.js yet.","messagePattern":"AI upgrades are not available for prerelease versions of Next\\.js yet\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/next/src/lib/upgrade/prepare-upgrade.ts","lineNumber":49,"sourceCode":"    )\n  }\n\n  // Resolve from the app: the invoking canary is only the upgrade tooling.\n  const requireFromApp = createRequire(join(directory, 'package.json'))\n  const installedNext = JSON.parse(\n    await readFile(requireFromApp.resolve('next/package.json'), 'utf8')\n  ) as {\n    version: string\n  }\n  const installedVersion = installedNext.version\n\n  if (!semver.valid(installedVersion)) {\n    throw new Error('Could not determine the installed Next.js version.')\n  }\n\n  // TODO: Handle prereleases\n  if (semver.prerelease(installedVersion)) {\n    throw new Error(\n      'AI upgrades are not available for prerelease versions of Next.js yet.'\n    )\n  }\n\n  if (targetRequest === 'latest' || targetRequest === 'future') {\n    const url = `${NPM_REGISTRY}next/latest`\n    const { value } = await fetchJSON(url)\n    const release = value as { version: string } | null\n\n    if (\n      !release ||\n      !semver.valid(release.version) ||\n      semver.prerelease(release.version)\n    ) {\n      throw new Error('Could not determine the latest stable Next.js version.')\n    }\n\n    const targetVersion =","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/vercel/next.js/blob/34433fd12ee8074ea3f47af9f36255c7390d0301/packages/next/src/lib/upgrade/prepare-upgrade.ts#L31-L67","documentation":"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.","triggerScenarios":"Running `next upgrade --ai` in an app whose package.json uses next@canary, next@rc, or a local build with a prerelease version suffix.","commonSituations":"Apps tracking canary for new features; contributors testing against next rc builds; monorepos where one workspace pins canary.","solutions":["Switch the app to a stable release: npm i next@latest (plus matching react/react-dom), then rerun the upgrade","Pin a stable version in package.json instead of a canary tag/dist-tag","If you must stay on canary, upgrade manually with npx @next/codemod@canary upgrade instead of --ai"],"exampleFix":"// before\n\"next\": \"canary\"\n// after\n\"next\": \"15.3.0\"","handlingStrategy":"validation","validationCode":"const semver = require('semver')\nconst v = require('next/package.json').version\nif (semver.prerelease(v)) {\n  console.error('AI upgrade requires a stable next release; current:', v)\n}","typeGuard":null,"tryCatchPattern":"try {\n  await prepareUpgrade(dir, 'latest')\n} catch (e) {\n  if (e.message.includes('prerelease')) {\n    // switch to next@latest or use manual @next/codemod upgrade\n  }\n}","preventionTips":["Pin stable next versions in apps; keep canary in throwaway branches","Check npm view next dist-tags before choosing a channel","Use the non-AI `npx @next/codemod@canary upgrade` path for prerelease channels"],"tags":["nextjs","upgrade","prerelease","unsupported"],"backgroundTag":"unsupported-operation","analyzedSha":"34433fd12ee8074ea3f47af9f36255c7390d0301","analyzedAt":"2026-09-20T18:20:20.576Z","contentChangedAt":"2026-09-20T18:20:20.576Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}