- Homebrew should be installed (Command line tools for Xcode are included).
-
Install
nvm
via Homebrew$
brew install nvm
-
Create system directory for nvm
$
mkdir ~/.nvm
-
Add following line to your profile. (
.profile
or.zshrc
or.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. (
.profile
or.zshrc
or.zprofile
)Example
- $
source ~/.profile
- $
source ~/.zshrc
- $
source ~/.zprofile
- $
-
Verify
nvm
is installed$
nvm -v
-
Check all avaliable version by this command
$
nvm ls-remote
-
Install NodeJS (Recommended to install LTS version. Current LTS is 8.10.0)
$
nvm install 8.10.0
-
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
yarn
via Homebrew withoutnode
dependencies$
brew install yarn --ignore-dependencies
-
Checkout
node
in environment$PATH
$
which node
It should be return =>
/User/<your's-user-name>/.nvm/versions/node/8.10.0/bin/node
-
Checkout
brew doctor
there should show message WARNING missing yarn dependencies$
brew doctor
-
Create symbol link from
nvm
for Homebrew$
ln -s ~/.nvm/versions/node/ /usr/local/Cellar/
** Note : If you installed multiple node versions via
nvm
. You should create symbol link by current global version. Following this commands **$
nvm current
=> v8.10.0$
mkdir /usr/local/Cellar/node
$
ln -s ~/.nvm/versions/node/8.10.0/ /usr/local/Cellar/node
-
Checkout
brew doctor
again. There shouldn't have WARNING message.$
brew doctor