How to configure my shell so that nvm use run automatically every time there\'s a .nvmrc file on the directory and use the latest version or a global config whe
Yet another solution using direnv. Direnv comes with OS X and many distros so no installation is needed.
Add these two lines to your .zshenv or .bash_profile depending on which shell you use:
export NVM_DIR="$HOME/.nvm" # You probably have this line already
export NODE_VERSIONS="${NVM_DIR}/versions/node"
export NODE_VERSION_PREFIX="v"
Add an .envrc file to the project root with the contents
set -e
use node
Finally cd to your directory. (Don't forget to source .zshenv)
direnv will ask you to allow load config.
Type direnv allow and voila!
Note that direnv doesn't support fancy constructs like lts/* in .nvrmc. On the positive side, direnv supports a bunch of runtimes like node, php, go, pyhton, ruby etc. allowing us to use a single tool to solve path issues.