{"record":{"id":"c81b4a107d84ae09","repo":"vercel/turborepo","slug":"turbo-to-does-not-exist","errorCode":null,"errorMessage":"turbo@${to} does not exist","messagePattern":"turbo@(.+?) does not exist","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/turbo-codemod/src/commands/migrate/steps/get-latest-version.ts","lineNumber":42,"sourceCode":"    throw new Error(`Unable to fetch the latest version of ${packageName}`);\n  }\n}\n\nexport async function getLatestVersion({\n  to\n}: MigrateCommandOptions): Promise<string | undefined> {\n  const packageDetails = await getPackageDetails({ packageName: \"turbo\" });\n  const { \"dist-tags\": tags, versions } = packageDetails;\n\n  if (to) {\n    // If 'to' is a dist-tag (e.g. \"latest\", \"canary\"), resolve to the concrete version\n    if (tags[to]) {\n      return tags[to];\n    }\n    if (to in versions) {\n      return to;\n    }\n    throw new Error(`turbo@${to} does not exist`);\n  }\n\n  return tags.latest;\n}\n","sourceCodeStart":24,"sourceCodeEnd":47,"githubUrl":"https://github.com/vercel/turborepo/blob/9f94a7d215b3881942527dd526afa3fc650869d5/packages/turbo-codemod/src/commands/migrate/steps/get-latest-version.ts#L24-L47","documentation":"When `turbo-codemod migrate` is given `--to <target>`, getLatestVersion accepts the value only if it is a known dist-tag (resolved via dist-tags, e.g. `latest`, `canary`) or an exact version present in the published `versions` map. Anything else throws `turbo@<to> does not exist`.","triggerScenarios":"Running migrate with an unpublished version (`--to 99.9.9`), a typo (`--to 2.3.4x`), a range (`--to ^2.3.0`), or an unknown tag name (`--to stable`).","commonSituations":"Assuming a tag exists because another tool uses it; copy-pasting a version from a blog post that was never released; guessing at the next canary version.","solutions":["List valid targets: `npm view turbo dist-tags --json` and `npm view turbo versions --json --last 20`","Re-run with a value that appears in one of those lists, e.g. `npx @turbo/codemod migrate --to latest` or `--to 2.3.17`","Omit --to entirely to accept `tags.latest` automatically"],"exampleFix":"# before\nnpx @turbo/codemod migrate --to 2.99.99\n# after\nnpm view turbo dist-tags   # find a real tag/version\nnpx @turbo/codemod migrate --to latest","handlingStrategy":"validation","validationCode":"import { execSync } from 'node:child_process';\n\nfunction isValidTurboTarget(target: string): boolean {\n  const tags = JSON.parse(execSync('npm view turbo dist-tags --json').toString());\n  const versions = new Set(JSON.parse(execSync('npm view turbo versions --json').toString()));\n  return target in tags || versions.has(target);\n}","typeGuard":"function isDistTagOrExactVersion(target: string, distTags: Record<string, string>, versions: string[]): boolean {\n  return target in distTags || versions.includes(target);\n}","tryCatchPattern":"try {\n  await migrate({ to });\n} catch (err) {\n  if (err instanceof Error && /does not exist/.test(err.message)) {\n    const tags = await npmView('turbo', 'dist-tags');\n    to = tags.latest; // fall back to a known-good target and re-run\n    return migrate({ to });\n  }\n  throw err;\n}","preventionTips":["Resolve `--to` values from `npm view turbo dist-tags`/`versions` output rather than typing them from memory","Accept exact versions or known tags only — ranges like ^2.3.0 are always rejected","Script the migration to default to `latest` when the requested target is unknown"],"tags":["turbo-codemod","version","npm-registry","migrate","validation"],"backgroundTag":"version-not-found-in-registry","analyzedSha":"9f94a7d215b3881942527dd526afa3fc650869d5","analyzedAt":"2026-08-16T19:47:29.531Z","schemaVersion":2},"datasetVersion":"2026-08-16T23:17:17.608Z"}