{"record":{"id":"5bf7951a5f7407f5","repo":"coreybutler/nvm-windows","slug":"a-version-argument-is-required-but-missing","errorCode":null,"errorMessage":"A version argument is required but missing.","messagePattern":"A version argument is required but missing\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/nvm.go","lineNumber":340,"sourceCode":"\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}\n\n\tif version == \"lts\" {\n\t\tversion = getLTS()\n\t}\n\n\tif version == \"newest\" {\n\t\tinstalled := node.GetInstalled(env.root)\n\t\tif len(installed) == 0 {\n\t\t\treturn version, \"\", errors.New(\"No versions of node.js found. Try installing the latest by typing nvm install latest.\")\n\t\t}\n","sourceCodeStart":322,"sourceCodeEnd":358,"githubUrl":"https://github.com/coreybutler/nvm-windows/blob/5b18223ca19ff50d707f35410dbc6bd440a9f74d/src/nvm.go#L322-L358","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Supply an explicit version, or the aliases \"latest\", \"node\", \"lts\", \"newest\" (e.g. `nvm install latest`).","In scripts, default the variable: `nvm install \"${NODE_VERSION:-latest}\".","If you expected .nvmrc support, read the version yourself and pass it: `nvm install $(cat .nvmrc)` (strip the leading 'v')."],"exampleFix":"# before\nnvm install\n# after\nnvm install latest","handlingStrategy":"validation","validationCode":"# bash: require or default a version before calling nvm\nVERSION=\"${NODE_VERSION:-latest}\"\n[ -n \"$VERSION\" ] || { echo \"NODE_VERSION is empty\" >&2; exit 1; }\nnvm install \"$VERSION\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass an explicit version or the latest/lts/newest aliases.","Set -u / null-check version variables in CI scripts before expanding them into nvm commands.","Remember nvm-windows does not read .nvmrc; read it yourself and pass the value."],"tags":["nvm-windows","missing-argument","input-validation","cli"],"backgroundTag":null,"analyzedSha":"5b18223ca19ff50d707f35410dbc6bd440a9f74d","analyzedAt":"2026-08-15T10:06:51.428Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}