{"record":{"id":"b6bd19afb899c3a8","repo":"coreybutler/nvm-windows","slug":"unable-to-move-directory-s-to-node-modules-v","errorCode":null,"errorMessage":"Unable to move directory %s to node_modules: %v","messagePattern":"Unable to move directory (.+?) to node_modules: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/nvm.go","lineNumber":810,"sourceCode":"\t\t\t\t\t\tmoveNpmErr = utility.Rename(npmSourcePath, filepath.Join(root, \"v\"+version, \"node_modules\", \"npm\"))\n\t\t\t\t\t\tif moveNpmErr == nil {\n\t\t\t\t\t\t\tbreak\n\t\t\t\t\t\t}\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\tif err == nil && moveNpmErr == nil {\n\t\t\t\t\terr = utility.Rename(filepath.Join(root, \"v\"+version), filepath.Join(env.root, \"v\"+version))\n\t\t\t\t\tif err != nil {\n\t\t\t\t\t\tstatus <- Status{Err: err}\n\t\t\t\t\t}\n\t\t\t\t\tif show_progress {\n\t\t\t\t\t\tstatus <- Status{Done: true}\n\t\t\t\t\t} else {\n\t\t\t\t\t\tstatus <- Status{Text: fmt.Sprintf(\"Installation complete. If you want to use this version, type\\n\\nnvm use %s\", version), Done: true}\n\t\t\t\t\t}\n\t\t\t\t} else if moveNpmErr != nil {\n\t\t\t\t\tstatus <- Status{Err: fmt.Errorf(\"Unable to move directory %s to node_modules: %v\", npmSourcePath, moveNpmErr), Done: true}\n\t\t\t\t} else {\n\t\t\t\t\tstatus <- Status{Err: fmt.Errorf(\"Failed to extract npm: %v\", err), Done: true}\n\t\t\t\t}\n\t\t\t} else {\n\t\t\t\terr = utility.Rename(filepath.Join(root, \"v\"+version), filepath.Join(env.root, \"v\"+version))\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\tnpmurl := web.GetFullNpmUrl(version)\n\t\t\t\tif show_progress {\n\t\t\t\t\t// Send special error notification with link to npm release when it cannot be downloaded\n\t\t\t\t\tnotify(Notification{\n\t\t\t\t\t\tTitle:   \"Download Failure (npm)\",\n\t\t\t\t\t\tMessage: fmt.Sprintf(\"Please download npm v%s manually and extract to %s\\\\v%s\", version, env.root, version),\n\t\t\t\t\t\tIcon:    \"error\",\n\t\t\t\t\t\tActions: []Action{\n\t\t\t\t\t\t\t{Type: \"protocol\", Label: \"Manually Download\", URI: npmurl},","sourceCodeStart":792,"sourceCodeEnd":828,"githubUrl":"https://github.com/coreybutler/nvm-windows/blob/5b18223ca19ff50d707f35410dbc6bd440a9f74d/src/nvm.go#L792-L828","documentation":"Sent (Done: true) when moveNpmErr != nil after install tried to move the freshly downloaded npm into the version's node_modules directory (the npmSourcePath rename). The version directory itself was already renamed into env.root, so node is installed but its bundled npm is missing.","triggerScenarios":"`nvm install <version>` where moving npmSourcePath into <root>\\v<version>\\node_modules fails: destination exists from a previous partial install, file locked by AV/indexer, or permissions on the nvm root.","commonSituations":"Retrying an install that previously half-completed (leftover node_modules\\npm); antivirus holding handles on freshly written files; nvm root on a network drive or synced folder with unreliable rename semantics.","solutions":["Fully remove the broken install first: `nvm uninstall <version>` (or delete <NVM_HOME>\\v<version>), then `nvm install <version>` again.","Run the shell elevated (Administrator) so renames under the nvm root succeed.","Exclude the nvm root from antivirus real-time scanning.","Keep NVM_HOME on a local, non-synced disk."],"exampleFix":"# before\nnvm install 20.11.0   # retries over a half-installed v20.11.0\n# after\nnvm uninstall 20.11.0\nnvm install 20.11.0","handlingStrategy":"fallback","validationCode":"# bash: detect a previous partial install before reinstalling\nif [ -d \"$NVM_HOME/v$V/node_modules/npm\" ] || [ -d \"$NVM_HOME/v$V\" ]; then\n  nvm uninstall \"$V\" 2>/dev/null || rm -rf \"$NVM_HOME/v$V\"\nfi\nnvm install \"$V\"","typeGuard":null,"tryCatchPattern":"nvm install \"$V\" || { nvm uninstall \"$V\"; nvm install \"$V\"; }","preventionTips":["Never layer installs over a failed one — uninstall (or delete the v<version> dir) first.","Run elevated so directory renames under NVM_HOME succeed.","Keep NVM_HOME on a local disk, outside sync/AV-scoped folders."],"tags":["nvm-windows","npm","filesystem","partial-install","permissions"],"backgroundTag":null,"analyzedSha":"5b18223ca19ff50d707f35410dbc6bd440a9f74d","analyzedAt":"2026-08-15T10:06:51.428Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}