Install Nodejs, npm and yarn on MacOS - lifeisegg2k/Study GitHub Wiki
Install Homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"
Install nodebrew
brew install nodebrew
Install Node.js
# Check the installable version
nodebrew ls-remote
# Usage
nodebrew install-binary {version}
# Get the latest version
nodebrew install-binary latest
# Get the stable version
nodebrew install-binary stable
# If an error occurs during installation
mkdir -p ~/.nodebrew/src
# List installed versions
nodebrew ls
# Activate installed version
nodebrew use {version}
# Add environment path
echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.bash_profile
# Reflect the environment
source ~/.bash_profile
# Check installed version
node -v
npm -v
Install yarn
brew install yarn
# Upgrade yarn
brew upgrade yarn
# Usage
yarn add {Package}
Reference