bashnvm

Bash check if nvm installed


How can I detirmine if nvm (Node Version Manager) is installed in bash?

I already have it installed in my system but I haven't been able to make any bash script that can detect it. I am making a script that should be used by others which depends on nvm, so I want to output if it's not installed and exit if it isn't..

This doesn't work: https://stackoverflow.com/a/26759734/846348 it says that nvm isn't installed but the bash script can use nvm..

Would be nice if it supported Mac Terminal, Mac iTerm and Windows with Linux shell at least.


Solution

  • One can check with command -v nvm:

    $ command -v nvm >/dev/null 2>&1 || { echo >&2 "nvm is required, but it's not installed.  Aborting."; exit 1; }