{"record":{"id":"ef411caf4ad38891","repo":"coreybutler/nvm-windows","slug":"s-is-not-a-valid-cpu-architecture-must-be-32","errorCode":null,"errorMessage":"\"%s\" is not a valid CPU architecture. Must be 32, 64, or arm64.","messagePattern":"\"(.+?)\" is not a valid CPU architecture\\. Must be 32, 64, or arm64\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/nvm.go","lineNumber":329,"sourceCode":"// BEGIN | CLI functions\n// ===============================================================\nfunc setNodeMirror(uri string) {\n\tenv.node_mirror = uri\n\tsaveSettings()\n}\n\nfunc setNpmMirror(uri string) {\n\tenv.npm_mirror = uri\n\tsaveSettings()\n}\n\nfunc getVersion(version string, cpuarch string, localInstallsOnly ...bool) (string, string, error) {\n\trequestedVersion := version\n\tcpuarch = strings.ToLower(cpuarch)\n\n\tif cpuarch != \"\" {\n\t\tif cpuarch != \"32\" && cpuarch != \"64\" && cpuarch != \"arm64\" && cpuarch != \"all\" {\n\t\t\treturn version, cpuarch, errors.New(\"\\\"\" + cpuarch + \"\\\" is not a valid CPU architecture. Must be 32, 64, or arm64.\")\n\t\t}\n\t} else {\n\t\tcpuarch = env.arch\n\t}\n\n\tif cpuarch != \"all\" {\n\t\tcpuarch = arch.Validate(cpuarch)\n\t}\n\n\tif version == \"\" {\n\t\treturn \"\", cpuarch, errors.New(\"A version argument is required but missing.\")\n\t}\n\n\t// If user specifies \"latest\" version, find out what version is\n\tif version == \"latest\" || version == \"node\" {\n\t\tversion = getLatest()\n\t\tfmt.Println(version)\n\t}","sourceCodeStart":311,"sourceCodeEnd":347,"githubUrl":"https://github.com/coreybutler/nvm-windows/blob/5b18223ca19ff50d707f35410dbc6bd440a9f74d/src/nvm.go#L311-L347","documentation":"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.","triggerScenarios":"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.","commonSituations":"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\".","solutions":["Pass one of the literal strings: 32, 64, arm64, or all (e.g. `nvm install 20.11.0 64`).","Omit the arch argument entirely so getVersion() defaults to env.arch, the architecture recorded in settings.","If scripting against $PROCESSOR_ARCHITECTURE, map AMD64->64, x86->32, ARM64->arm64 before passing it.","Check `nvm arch` to see/change the persisted default architecture instead of passing it per-command."],"exampleFix":"# before\nnvm install 20.11.0 x86_64\n# after\nnvm install 20.11.0 64","handlingStrategy":"validation","validationCode":"# bash wrapper before invoking nvm\ncase \"${2,,}\" in\n  \"\"|32|64|arm64|all) ;;\n  amd64|x86_64)  arg=64 ;;\n  x86|i386)      arg=32 ;;\n  aarch64)       arg=arm64 ;;\n  *) echo \"invalid arch: $2\" >&2; exit 2 ;;\nesac\nnvm install \"$1\" \"$arg\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Hard-code only 32/64/arm64/all in scripts that pass an arch.","Omit the arch argument to inherit the persisted `nvm arch` default.","Map OS arch names (amd64, x86_64, aarch64) to nvm's literals before passing them."],"tags":["nvm-windows","cpu-architecture","input-validation","cli"],"backgroundTag":null,"analyzedSha":"5b18223ca19ff50d707f35410dbc6bd440a9f74d","analyzedAt":"2026-08-15T10:06:51.428Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}