coreybutler/nvm-windows · error

"%s" is not a valid CPU architecture. Must be 32, 64, or arm

Error message

"%s" is not a valid CPU architecture. Must be 32, 64, or arm64.

What it means

Thrown by getVersion() in src/nvm.go when the cpuarch argument is non-empty but is not one of the accepted literals "32", "64", "arm64", or "all". The check is case-insensitive (the input is lowercased first), so any other spelling fails. This guards the arch.Validate() normalization step that follows.

Source

Thrown at src/nvm.go:329

// BEGIN | CLI functions
// ===============================================================
func setNodeMirror(uri string) {
	env.node_mirror = uri
	saveSettings()
}

func setNpmMirror(uri string) {
	env.npm_mirror = uri
	saveSettings()
}

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)
	}

View on GitHub (pinned to 5b18223ca1)

Solutions

  1. Pass one of the literal strings: 32, 64, arm64, or all (e.g. `nvm install 20.11.0 64`).
  2. Omit the arch argument entirely so getVersion() defaults to env.arch, the architecture recorded in settings.
  3. If scripting against $PROCESSOR_ARCHITECTURE, map AMD64->64, x86->32, ARM64->arm64 before passing it.
  4. Check `nvm arch` to see/change the persisted default architecture instead of passing it per-command.

Example fix

# before
nvm install 20.11.0 x86_64
# after
nvm install 20.11.0 64
Defensive patterns

Strategy: validation

Validate before calling

# bash wrapper before invoking nvm
case "${2,,}" in
  ""|32|64|arm64|all) ;;
  amd64|x86_64)  arg=64 ;;
  x86|i386)      arg=32 ;;
  aarch64)       arg=arm64 ;;
  *) echo "invalid arch: $2" >&2; exit 2 ;;
esac
nvm install "$1" "$arg"

Prevention

When it happens

Trigger: Calling a command that routes through getVersion(version, cpuarch) with a bad arch string, e.g. `nvm install 20.11.0 x86`, `nvm use 20 x64`, or `nvm install 20 ARM` (ok, lowercased) vs `nvm install 20 win64` (fails). Also machine arch strings like "amd64" or "x86_64" fail because Validate() only substring-matches "arm64"/"64" after this gate rejects unknown values.

Common situations: Users coming from Unix nvm or docker platform syntax (amd64, x86_64, win-x64); shell scripts that pass $PROCESSOR_ARCHITECTURE verbatim (e.g. "AMD64" works only because lowercasing yields "amd64" which contains... actually fails the whitelist, then Validate would map it, but the whitelist rejects it first); typos like "aarch64".

Related errors


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