- Homebrew should be installed (Command line tools for Xcode are included).
-
Install
nvmvia Homebrew$
brew install nvm -
Create system directory for nvm
$
mkdir ~/.nvm -
Add following line to your profile. (
.profileor.zshrcor.zprofile)# NVM export NVM_DIR=~/.nvm source $(brew --prefix nvm)/nvm.sh
-
Close and open your terminal again. Or Choose one from the following command once for reload your profile. (
.profileor.zshrcor.zprofile)Example
- $
source ~/.profile - $
source ~/.zshrc - $
source ~/.zprofile
- $
-
Verify
nvmis installed$
nvm --version -
Check all avaliable version by this command
$
nvm ls-remote -
Install NodeJS (Recommended to install LTS version. Current LTS is Dubnium)
$
nvm install --lts='Dubnium' -
Check installed NodeJS in your machine.
$
nvm ls -
Set global nodejs version to environment.
$
nvm use default
See more about nvm : https://github.com/creationix/nvm
-
Install
yarnvia Homebrew and removenodedependencies from Homebrew$
brew install yarn$
brew uninstall node --ignore-dependencies -
Checkout
nodein environment$PATH$
which nodeIt should be return =>
/User/<your's-user-name>/.nvm/versions/node/<latest-node-lts-version>/bin/node -
Checkout
brew doctorthere should show message WARNING missing yarn dependencies$
brew doctor -
Create symbol link from
nvmfor Homebrew. Pick a choice which suitable for you.a. This is for those who installed only one version via nvm
$
ln -s ~/.nvm/versions/node/ /usr/local/Cellar/b. If you installed multiple node versions via
nvm. You should create symbol link by current global version. Following this commands$
nvm current=> v10.16.0 (Latest LTS: Dubnium) (This should be Global node version)$
mkdir /usr/local/Cellar/node$
ln -s ~/.nvm/versions/node/<latest-node-lts-version>/ /usr/local/Cellar/node -
Checkout
brew doctoragain. There shouldn't have WARNING message.$
brew doctor