{"record":{"id":"8e574d9d9882287c","repo":"coreybutler/nvm-windows","slug":"failed-to-extract-npm-could-not-find-s","errorCode":null,"errorMessage":"Failed to extract npm. Could not find %s","messagePattern":"Failed to extract npm\\. Could not find (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/nvm.go","lineNumber":767,"sourceCode":"\t\t\t\t}\n\t\t\t\tdefer os.RemoveAll(tempDir)\n\n\t\t\t\t// Extract npm to the temp directory\n\t\t\t\terr = file.Unzip(filepath.Join(tempDir, \"npm-v\"+npmv+\".zip\"), filepath.Join(tempDir, \"nvm-npm\"))\n\t\t\t\tif err != nil {\n\t\t\t\t\tstatus <- Status{Err: err}\n\t\t\t\t}\n\n\t\t\t\t// Copy the npm and npm.cmd files to the installation directory\n\t\t\t\ttempNpmBin := filepath.Join(tempDir, \"nvm-npm\", \"cli-\"+npmv, \"bin\")\n\n\t\t\t\t// Support npm < 6.2.0\n\t\t\t\tif file.Exists(tempNpmBin) == false {\n\t\t\t\t\ttempNpmBin = filepath.Join(tempDir, \"nvm-npm\", \"npm-\"+npmv, \"bin\")\n\t\t\t\t}\n\n\t\t\t\tif file.Exists(tempNpmBin) == false {\n\t\t\t\t\tstatus <- Status{Err: fmt.Errorf(\"Failed to extract npm. Could not find %s\", tempNpmBin), Done: true}\n\t\t\t\t\treturn\n\t\t\t\t}\n\n\t\t\t\t// Standard npm support\n\t\t\t\tutility.Rename(filepath.Join(tempNpmBin, \"npm\"), filepath.Join(root, \"v\"+version, \"npm\"))\n\t\t\t\tutility.Rename(filepath.Join(tempNpmBin, \"npm.cmd\"), filepath.Join(root, \"v\"+version, \"npm.cmd\"))\n\n\t\t\t\t// npx support\n\t\t\t\tif _, err := os.Stat(filepath.Join(tempNpmBin, \"npx\")); err == nil {\n\t\t\t\t\tutility.Rename(filepath.Join(tempNpmBin, \"npx\"), filepath.Join(root, \"v\"+version, \"npx\"))\n\t\t\t\t\tutility.Rename(filepath.Join(tempNpmBin, \"npx.cmd\"), filepath.Join(root, \"v\"+version, \"npx.cmd\"))\n\t\t\t\t}\n\n\t\t\t\tnpmSourcePath := filepath.Join(tempDir, \"nvm-npm\", \"npm-\"+npmv)\n\n\t\t\t\tif file.Exists(npmSourcePath) == false {\n\t\t\t\t\tnpmSourcePath = filepath.Join(tempDir, \"nvm-npm\", \"cli-\"+npmv)\n\t\t\t\t}","sourceCodeStart":749,"sourceCodeEnd":785,"githubUrl":"https://github.com/coreybutler/nvm-windows/blob/5b18223ca19ff50d707f35410dbc6bd440a9f74d/src/nvm.go#L749-L785","documentation":"Sent (Done: true) during npm installation when the extracted npm archive does not contain a bin directory at either <tempDir>\\nvm-npm\\cli-<npmv>\\bin (npm >= 6.2.0 layout) or <tempDir>\\nvm-npm\\npm-<npmv>\\bin (older layout). It means the npm zip downloaded from web.GetFullNpmUrl(version) extracted to an unexpected structure.","triggerScenarios":"`nvm install <version>` on a machine whose npm mirror (env.npm_mirror, set via setNpmMirror) serves an npm tarball with a different top-level layout, or where extraction silently failed (disk full, AV quarantine, path-length limits) leaving no bin/ folder.","commonSituations":"Using npm mirrors (npmmirror.com/taobao) that repackage npm; long %TEMP% paths exceeding MAX_PATH on extraction; proxy returning an HTML error page that 'extracted' to nothing; very old npm versions bundled with very old node.","solutions":["Reset the npm mirror to the registry default: `nvm npm_mirror https://github.com/npm/cli/archive/` style official URL, or unset custom mirror settings.","Clear %TEMP%\\nvm-npm* leftovers, enable long paths (gpedit/registry LongPathsEnabled), free disk space, retry.","Disable AV scanning on TEMP during install.","If it still fails, complete manually: download npm for that version from the printed URL and extract to <NVM_ROOT>\\v<version>\\node_modules\\npm with bin\\npm copied to <NVM_ROOT>\\v<version>\\npm."],"exampleFix":"# before\nnvm npm_mirror https://registry.npmmirror.com/-/binary/npm\n# after\nnvm npm_mirror https://github.com/npm/cli/archive\nnvm install 20.11.0","handlingStrategy":"fallback","validationCode":"# bash: verify the npm mirror serves the expected archive shape before install\ncurl -sfI \"${NVM_NPM_MIRROR:-https://github.com/npm/cli/archive}/v$(nvm ls | grep -oP '\\d+\\.\\d+\\.\\d+' | head -1).tar.gz\" >/dev/null || echo 'npm mirror unreachable' >&2","typeGuard":null,"tryCatchPattern":"nvm install \"$V\" || { echo 'npm extraction failed — installing node then npm manually'; nvm uninstall \"$V\"; }","preventionTips":["Prefer the official npm archive URL over repackaging mirrors.","Enable Windows long paths and keep %TEMP% short to avoid extraction truncation.","Exclude TEMP and NVM_HOME from antivirus during installs."],"tags":["nvm-windows","npm","extraction","mirror","install"],"backgroundTag":null,"analyzedSha":"5b18223ca19ff50d707f35410dbc6bd440a9f74d","analyzedAt":"2026-08-15T10:06:51.428Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}