Skip to content

Commit

Permalink
Added a debug check to identify invalid Node installations.
Browse files Browse the repository at this point in the history
  • Loading branch information
coreybutler committed Apr 20, 2023
1 parent 026d2de commit 0990c1f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/nvm.go
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,25 @@ func checkLocalEnvironment() {
}
}

v := node.GetInstalled(env.root)
invalid := make([]string, 0)
invalidnpm := make([]string, 0)
for i := 0; i < len(v); i++ {
if _, err = os.Stat(filepath.Join(env.root, v[i], "node.exe")); err != nil {
invalid = append(invalid, v[i])
} else if _, err = os.Stat(filepath.Join(env.root, v[i], "npm.cmd")); err != nil {
invalidnpm = append(invalid, v[i])
}
}

if len(invalid) > 0 {
problems = append(problems, "The following Node installations are invalid (missing node.exe): "+strings.Join(invalid, ", ")+" - consider reinstalling these versions")
}

if len(invalidnpm) > 0 {
fmt.Printf("\nWARNING: The following Node installations are missing npm: %v\n (Node will still run, but npm will not work on these versions)\n", strings.Join(invalidnpm, ", "))
}

if len(env.npm_mirror) > 0 {
fmt.Println("If you are experiencing npm problems, check the npm mirror (" + env.npm_mirror + ") to assure it is online and accessible.")
}
Expand Down

0 comments on commit 0990c1f

Please sign in to comment.