nvm: command not found。
. ~/.nvm/nvm.sh nvm use 8.9.4
. $(brew --prefix nvm)/nvm.sh nvm use 8.9.4
The reason that nvm is a shell function and not a script is because it works by changing the environment of your current shell. This is a major design decision and the thing that makes nvm different from n and nave. n works by creating global symlinks to different node versions. nave works by creating a new subshell with the desired env modifications. I decided to go the less intrusive route and only modify the current shell. Mostly it just mucks around with $PATH so that the desired version of node is first on the path. Other shells can concurrently use their own local node version unmolested. I do this without the overhead of creating new subshells or changing global paths.
Only shell functions can do what I want. The major drawback obviously is it confuses people who think nvm.sh is a shell script meant to be run in a subshell like every other sh file they've seen. I'm sorry for the confusion but it is what it is. Subshells can't modify their parent's environment.