0

I installed nvm using the Windows installer, and all of the nvm commands work in the Git CMD, but don't work in the Windows CMD:

'nvm' is not recognized as an internal or external command

Why / how did the Git CMD automatically pick up on the installation but Windows CMD didn't?

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257
mitmath514
  • 347
  • 1
  • 4
  • 9
  • 3
    As a simple sanity check, compare the `PATH` of both environments. `echo %PATH%` for the Windows command line, `echo $PATH` for Git Bash. – miqh Apr 03 '19 at 04:44
  • to run `npm`, use `call npm`, since I think it's a batch script on its own (this doesn't solve the path issue though, of course)... – aschipfl Apr 03 '19 at 08:23
  • Possible duplicate of [What is the reason for "X is not recognized as an internal or external command, operable program or batch file"?](https://stackoverflow.com/questions/41454769/what-is-the-reason-for-x-is-not-recognized-as-an-internal-or-external-command) – Selaron Apr 03 '19 at 09:27
  • 1
    @Mofi, @Selaron, I don't think that's a good duplicate in this case. nvm is a _bash script_, not a binary program. Fixing the `PATH` won't make it run on `cmd.exe`. – ChrisGPT was on strike Apr 03 '19 at 10:20
  • OP, I can't find a Windows installer for nvm. Are you using something else, like [nvm-windows](https://github.com/coreybutler/nvm-windows) (an unrelated but similar tool written in Go)? – ChrisGPT was on strike Apr 03 '19 at 19:11

1 Answers1

3

The comments focusing on your %PATH% may be relevant, but they only point to a small part of the problem. In this case I think they're more misleading than helpful.

nvm is a

Simple bash script to manage multiple active node.js versions

(bold added)

nvm isn't exactly a standalone program, and (perhaps surprisingly) it isn't written in JavaScript. It's a script written for bash, the default shell on most Linux machines (though it also works with zsh and may work on other related shells like the Bourne shell). On Windows, Git comes with Bash and I strongly suspect when you say "Git CMD" you really mean that Bash shell.

Windows' cmd.exe is a completely different animal. PowerShell is closer to bash than cmd.exe, but it's still very different and scripts aren't compatible between the two.

This is a bit like asking why a Perl script doesn't run on Python. They're simply different languages.

ChrisGPT was on strike
  • 127,765
  • 105
  • 273
  • 257