coreybutler/nvm-windows · error

Failed to extract npm: %v

Error message

Failed to extract npm: %v

What it means

Sent (Done: true) on the else-branch where moveNpmErr is nil but the npm extraction step returned err != nil — the npm archive download/unzip itself failed before any move was attempted. Node.exe is installed at this point, but npm is not.

Source

Thrown at src/nvm.go:812

							break
						}
					}
				}

				if err == nil && moveNpmErr == nil {
					err = utility.Rename(filepath.Join(root, "v"+version), filepath.Join(env.root, "v"+version))
					if err != nil {
						status <- Status{Err: err}
					}
					if show_progress {
						status <- Status{Done: true}
					} else {
						status <- Status{Text: fmt.Sprintf("Installation complete. If you want to use this version, type\n\nnvm use %s", version), Done: true}
					}
				} else if moveNpmErr != nil {
					status <- Status{Err: fmt.Errorf("Unable to move directory %s to node_modules: %v", npmSourcePath, moveNpmErr), Done: true}
				} else {
					status <- Status{Err: fmt.Errorf("Failed to extract npm: %v", err), Done: true}
				}
			} else {
				err = utility.Rename(filepath.Join(root, "v"+version), filepath.Join(env.root, "v"+version))
				if err != nil {
					status <- Status{Err: err}
				}

				npmurl := web.GetFullNpmUrl(version)
				if show_progress {
					// Send special error notification with link to npm release when it cannot be downloaded
					notify(Notification{
						Title:   "Download Failure (npm)",
						Message: fmt.Sprintf("Please download npm v%s manually and extract to %s\\v%s", version, env.root, version),
						Icon:    "error",
						Actions: []Action{
							{Type: "protocol", Label: "Manually Download", URI: npmurl},
						},
					})

View on GitHub (pinned to 5b18223ca1)

Solutions

  1. Retry; if persistent, reset the npm mirror: `nvm npm_mirror <official-url>`.
  2. Verify network/proxy (`nvm proxy`) and that the printed npm URL is reachable from the machine.
  3. Free %TEMP% space and clear nvm-npm temp dirs.
  4. Finish manually: download the npm archive named in the follow-up message, extract it under <NVM_ROOT>\v<version> as instructed, or `nvm uninstall` + reinstall cleanly.

Example fix

# before
nvm install 20.11.0   # npm download fails
# after
nvm npm_mirror https://github.com/npm/cli/archive
nvm install 20.11.0
Defensive patterns

Strategy: retry

Validate before calling

# bash: pre-flight the npm archive URL
curl -sfI "$NPM_URL" >/dev/null || { echo "npm archive unreachable: $NPM_URL" >&2; exit 1; }
nvm install "$V"

Try / catch

for i in 1 2 3; do nvm install "$V" && exit 0; sleep $((i*5)); done; echo 'npm fetch kept failing — check npm_mirror/proxy' >&2; exit 1

Prevention

When it happens

Trigger: `nvm install <version>` where fetching or unzipping the npm tarball from web.GetFullNpmUrl(version) fails: npm mirror unreachable, HTTP error returned, archive truncated, or extraction hit disk-full/permission problems.

Common situations: Custom npm_mirror pointing to a stale or incomplete mirror; npm.github.io/cli archive access blocked by firewall; %TEMP% full; proxy misconfigured so only the node zip succeeded (cached) while npm fetch failed.

Related errors


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