coreybutler/nvm-windows · error

A version argument is required but missing.

Error message

A version argument is required but missing.

What it means

Returned by getVersion() when the version argument is the empty string. The function resolves the arch first, then hard-fails because there is no version to resolve. It is a pure argument-validation error, not an environment problem.

Source

Thrown at src/nvm.go:340

func getVersion(version string, cpuarch string, localInstallsOnly ...bool) (string, string, error) {
	requestedVersion := version
	cpuarch = strings.ToLower(cpuarch)

	if cpuarch != "" {
		if cpuarch != "32" && cpuarch != "64" && cpuarch != "arm64" && cpuarch != "all" {
			return version, cpuarch, errors.New("\"" + cpuarch + "\" is not a valid CPU architecture. Must be 32, 64, or arm64.")
		}
	} else {
		cpuarch = env.arch
	}

	if cpuarch != "all" {
		cpuarch = arch.Validate(cpuarch)
	}

	if version == "" {
		return "", cpuarch, errors.New("A version argument is required but missing.")
	}

	// If user specifies "latest" version, find out what version is
	if version == "latest" || version == "node" {
		version = getLatest()
		fmt.Println(version)
	}

	if version == "lts" {
		version = getLTS()
	}

	if version == "newest" {
		installed := node.GetInstalled(env.root)
		if len(installed) == 0 {
			return version, "", errors.New("No versions of node.js found. Try installing the latest by typing nvm install latest.")
		}

View on GitHub (pinned to 5b18223ca1)

Solutions

  1. Supply an explicit version, or the aliases "latest", "node", "lts", "newest" (e.g. `nvm install latest`).
  2. In scripts, default the variable: `nvm install "${NODE_VERSION:-latest}".
  3. If you expected .nvmrc support, read the version yourself and pass it: `nvm install $(cat .nvmrc)` (strip the leading 'v').

Example fix

# before
nvm install
# after
nvm install latest
Defensive patterns

Strategy: validation

Validate before calling

# bash: require or default a version before calling nvm
VERSION="${NODE_VERSION:-latest}"
[ -n "$VERSION" ] || { echo "NODE_VERSION is empty" >&2; exit 1; }
nvm install "$VERSION"

Prevention

When it happens

Trigger: Invoking an install/use style command with no version operand (e.g. `nvm install` or `nvm use`) so the command dispatcher calls getVersion("", arch). Also a wrapper script that builds `nvm use $NODE_VER` with an unset/empty variable.

Common situations: CI pipelines where the version env var is not exported; users expecting bare `nvm install` to behave like Unix nvm's `.nvmrc` support (nvm-windows has none); quoting mistakes that expand to an empty string.

Related errors


AI-assisted analysis of coreybutler/nvm-windows@5b18223ca1 (2026-08-15). Data as JSON: /api/errors/5bf7951a5f7407f5. Report an issue: GitHub.