coreybutler/nvm-windows · error

Error rolling back node v%s installation: %v.

Error message

Error rolling back node v%s installation: %v.

What it means

Returned by rollback() when os.Lstat on <env.root>\v<version> fails with something other than NotExist (e.g. access denied, path too long, stale handle). NotExist is the expected 'nothing to roll back' case and returns nil; any other stat failure is wrapped into this error. The name is misleading: it fires while inspecting the directory, before any deletion happens.

Source

Thrown at src/nvm.go:413

	return version, cpuarch, err
}

type Status struct {
	Text string
	Err  error
	Done bool
	Help bool
}

func rollback(version string) error {
	p := filepath.Join(env.root, "v"+version)

	_, err := os.Lstat(p)
	if err != nil {
		if !os.IsNotExist(err) {
			writeToErrorLog(err)
			return fmt.Errorf("Error rolling back node v%s installation: %v.", version, err)
		}
	}

	return nil
}

func install(version string, cpuarch string) {
	requestedVersion := version
	args := os.Args
	lastarg := args[len(args)-1]

	if lastarg == "--insecure" {
		env.verifyssl = false
	}

	if strings.HasPrefix(version, "--") {
		fmt.Println("\"--\" prefixes are unnecessary in NVM for Windows!")
		version = strings.ReplaceAll(version, "-", "")

View on GitHub (pinned to 5b18223ca1)

Solutions

  1. Re-run the command as Administrator (nvm-windows normally requires elevation for its root operations).
  2. Exclude the NVM_HOME directory from real-time antivirus scanning.
  3. Close programs (Explorer windows, editors, running node.exe) that hold handles under the nvm root and retry.
  4. If persistent, run `nvm uninstall <version>` to force cleanup, or manually delete <NVM_HOME>\v<version> and reinstall.
Defensive patterns

Strategy: retry

Validate before calling

# bash: pre-flight the target dir is stat-able and not locked
DIR="$NVM_HOME/v$VERSION"
if [ -e "$DIR" ] && [ ! -w "$DIR" ]; then echo "no write access to $DIR" >&2; exit 1; fi

Try / catch

for i in 1 2 3; do nvm install "$V" && break; echo "attempt $i failed (possible file lock)"; sleep 5; done

Prevention

When it happens

Trigger: During install() cleanup after a failed install, rollback() stats C:\<nvm-root>\v20.11.0 and hits ERROR_ACCESS_DENIED (locked by another process), ERROR_SHARING_VIOLATION (antivirus scanning), or an invalid path. It is sent on the status channel when the initial install goroutine fails and cleanup is attempted.

Common situations: Antivirus/Windows Defender locking freshly-created node directories; the directory is open in Explorer or a terminal; ACL/permission problems on the nvm root (e.g. root moved to a protected folder); OneDrive-synced nvm roots.

Related errors


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