Move from this Gist
Pull request is available. Please help me contribute this one 😂.
- Homebrew should be installed (Command line tools for Xcode are included).
-
Install
nvm
via Homebrew$
brew install 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 --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
yarn
via Homebrew$
brew install yarn
-
Remove
node
dependencies from Homebrew$
brew uninstall node --ignore-dependencies
-
Checkout
node
in environment$PATH
$
which node
It should be return =>
/User/<your's-user-name>/.nvm/versions/node/<latest-node-lts-version>/bin/node
-
Checkout
brew doctor
there should show message WARNING missing yarn dependencies$
brew doctor
-
Create symbol link from
nvm
foryarn
in Homebrew.$
nvm current
=> v10.16.0 (Latest LTS: Dubnium) (This should be Global node version)$
mkdir /usr/local/Cellar/node
$
ln -s ~/.nvm/versions/node/$(nvm current)/ /usr/local/Cellar/node
-
Overwrite
node, npm and npx
from linkednode
in/usr/local/Cellar/node
to/usr/local/bin/
homebrew$
brew link --overwrite node
-
Checkout
ls -la /usr/local/bin
to see overwritednode, npm and npx
-
Checkout
brew doctor
again. There shouldn't have WARNING message.$
brew doctor
-
Prevent Homebrew upgrading node version
$
brew pin node
-
Enjoy ! ❤️
TODO here