vuejs/core · error · Error

invalid target version: ${targetVersion}

Error message

invalid target version: ${targetVersion}

What it means

Thrown by Vue's release script (scripts/release.js) when the resolved targetVersion fails semver.valid() after increment resolution. The script derives targetVersion from CLI args / a release-type prompt, optionally bumps it via semver.inc, and rejects anything that is not a valid semver. release.js:185 hard-fails before prompting for confirmation.

Source

Thrown at scripts/release.js:185

        type: 'input',
        name: 'version',
        message: 'Input custom version',
        initial: currentVersion,
      })
      targetVersion = result.version
    } else {
      targetVersion = release.match(/\((.*)\)/)?.[1] ?? ''
    }
  }

  // @ts-expect-error
  if (versionIncrements.includes(targetVersion)) {
    // @ts-expect-error
    targetVersion = inc(targetVersion)
  }

  if (!semver.valid(targetVersion)) {
    throw new Error(`invalid target version: ${targetVersion}`)
  }

  if (skipPrompts) {
    step(`Releasing v${targetVersion}...`)
  } else {
    /** @type {{ yes: boolean }} */
    const { yes: confirmRelease } = await prompt({
      type: 'confirm',
      name: 'yes',
      message: `Releasing v${targetVersion}. Confirm?`,
    })

    if (!confirmRelease) {
      return
    }
  }

  await runTestsIfNeeded()

View on GitHub (pinned to a2b40db9a8)

Solutions

  1. Pass a valid release type: `node scripts/release.js patch` (or minor/major), or a full version like `3.4.0`.
  2. If specifying a prerelease, use the format the script expects (e.g. `beta` with a matching dist-tag).
  3. Run the script without arguments to use the interactive prompt instead of guessing.
  4. Check that the working version in package.json is itself valid semver so inc() can operate.

Example fix

// before
node scripts/release.js rel
// -> invalid target version: rel

// after
node scripts/release.js patch
Defensive patterns

Strategy: validation

Validate before calling

// Validate the release argument before invoking the script.
const semver = require('semver')
const increments = ['major', 'minor', 'patch', 'prepatch', 'prerelease']
function isValidReleaseArg(arg: string) {
  return increments.includes(arg) || semver.valid(arg) !== null
}
if (!isValidReleaseArg(process.argv[2])) {
  throw new Error(`Invalid release argument: ${process.argv[2]}. Use major|minor|patch or a semver version.`)
}

Type guard

function isReleaseType(arg: string): boolean {
  return ['major', 'minor', 'patch', 'prepatch', 'prerelease'].includes(arg) || semver.valid(arg) !== null
}

Prevention

When it happens

Trigger: Running `node scripts/release.js <arg>` with an argument that is neither a release type (major/minor/patch/prepatch/...) nor a valid version; passing a malformed explicit version like `1.2` or `vfoo`; an increment that produced an empty string (the `?? ''` fallback when no `(type)` group is matched).

Common situations: Typo in the release-type argument; passing a tag/prerelease string the script cannot parse; invoking the script with no usable argument in a non-interactive (skipPrompts) context.

Related errors


AI-assisted analysis of vuejs/core@a2b40db9a8 (2026-08-12). Data as JSON: /api/errors/36caa6e794ad8773. Report an issue: GitHub.