# Install NVM, NodeJS, Yarn via Homebrew
## Prerequisites
- [Homebrew](https://brew.sh/) should be installed (Command line tools for Xcode are included).
## Getting start
### Install NVM and NodeJS
1. Install `nvm` via Homebrew
$ `brew install nvm`
2. Create system directory for nvm
$ `mkdir ~/.nvm`
3. Add following line to your profile. (`.profile` or `.zshrc` or `.zprofile`)
```bash
# NVM
export NVM_DIR=~/.nvm
source $(brew --prefix nvm)/nvm.sh
```
4. 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`
5. Verify `nvm` is installed
$ `nvm -v`
6. Check all avaliable version by this command
$ `nvm ls-remote`
7. Install NodeJS (_Recommended to install LTS version. Current LTS is 8.10.0_)
$ `nvm install 8.10.0`
8. Check installed NodeJS in your machine.
$ `nvm ls`
9. Set global nodejs version to environment.
$ `nvm use default`
See more about `nvm` : https://github.com/creationix/nvm
### Install Yarn
1. Install `yarn` via Homebrew without `node` dependencies
$ `brew install yarn --ignore-dependencies`
2. Checkout `node` in environment `$PATH`
$ `which node`
It should be return => `/User/<your's-user-name>/.nvm/versions/node/8.10.0/bin/node`
3. Checkout `brew doctor` there should show message **WARNING missing yarn dependencies**
$ `brew doctor`
4. 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`
4. Checkout `brew doctor` again. There shouldn't have **WARNING** message.
$ `brew doctor`