Just install this library: https://github.com/wbyoung/avn
$ npm install -g avn avn-nvm avn-n
$ avn setup
Then in the root of your node js app create a file, for example:
$ echo 8.5.0 > .nvmrc or node -v > .nvmrc
Edit ~/.bash_profile and add this script:
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[[ -s "$HOME/.avn/bin/avn.sh" ]] && source "$HOME/.avn/bin/avn.sh" # load avn
Node Version Manager – https://github.com/nvm-sh/nvm
Node version switching – https://github.com/wbyoung/avn