brew install node@8
node@8 is keg-only, which means it was not symlinked into /usr/local,
because this is an alternate version of another formula.
If you need to have node@8 first in your PATH run:
echo 'export PATH="/usr/local/opt/node@8/bin:$PATH"' >> ~/.bash_profile
For compilers to find node@8 you may need to set:
export LDFLAGS="-L/usr/local/opt/node@8/lib"
export CPPFLAGS="-I/usr/local/opt/node@8/include"
nvm
export NVM_DIR="/usr/local/Cellar/nvm/0.33.11/"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm