coreybutler/nvm-windows · error
Failed to extract npm. Could not find %s
Error message
Failed to extract npm. Could not find %s
What it means
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.
Source
Thrown at src/nvm.go:767
}
defer os.RemoveAll(tempDir)
// Extract npm to the temp directory
err = file.Unzip(filepath.Join(tempDir, "npm-v"+npmv+".zip"), filepath.Join(tempDir, "nvm-npm"))
if err != nil {
status <- Status{Err: err}
}
// Copy the npm and npm.cmd files to the installation directory
tempNpmBin := filepath.Join(tempDir, "nvm-npm", "cli-"+npmv, "bin")
// Support npm < 6.2.0
if file.Exists(tempNpmBin) == false {
tempNpmBin = filepath.Join(tempDir, "nvm-npm", "npm-"+npmv, "bin")
}
if file.Exists(tempNpmBin) == false {
status <- Status{Err: fmt.Errorf("Failed to extract npm. Could not find %s", tempNpmBin), Done: true}
return
}
// Standard npm support
utility.Rename(filepath.Join(tempNpmBin, "npm"), filepath.Join(root, "v"+version, "npm"))
utility.Rename(filepath.Join(tempNpmBin, "npm.cmd"), filepath.Join(root, "v"+version, "npm.cmd"))
// npx support
if _, err := os.Stat(filepath.Join(tempNpmBin, "npx")); err == nil {
utility.Rename(filepath.Join(tempNpmBin, "npx"), filepath.Join(root, "v"+version, "npx"))
utility.Rename(filepath.Join(tempNpmBin, "npx.cmd"), filepath.Join(root, "v"+version, "npx.cmd"))
}
npmSourcePath := filepath.Join(tempDir, "nvm-npm", "npm-"+npmv)
if file.Exists(npmSourcePath) == false {
npmSourcePath = filepath.Join(tempDir, "nvm-npm", "cli-"+npmv)
}View on GitHub (pinned to 5b18223ca1)
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.
Example fix
# before nvm npm_mirror https://registry.npmmirror.com/-/binary/npm # after nvm npm_mirror https://github.com/npm/cli/archive nvm install 20.11.0
Defensive patterns
Strategy: fallback
Validate before calling
# bash: verify the npm mirror serves the expected archive shape before install
curl -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 Try / catch
nvm install "$V" || { echo 'npm extraction failed — installing node then npm manually'; nvm uninstall "$V"; } Prevention
- 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.
When it happens
Trigger: `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.
Common situations: 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.
Related errors
- Failed to extract npm: %v
- Could not download npm for node v%s. Please visit %s to down
- Node.js v%s is only available in 32-bit and 64-bit.
- Version %s is not available. The complete list of available
- "%s" is not a valid version. Please use a valid semantic ver
AI-assisted analysis of coreybutler/nvm-windows@5b18223ca1 (2026-08-15).
Data as JSON: /api/errors/8e574d9d9882287c.
Report an issue: GitHub.