nodebrewとは
macでのNode.jsバージョン管理ツールです。
nodebrewのインストール
ターミナルを起動し、以下コマンドを実行し、Homebrewをインストールしましょう。
※Homebrewは、macOS用のパッケージ管理マネージャです。
管理者パスワードを求められるので入力しましょう。
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
次に以下コマンドを実行し、nodebrewをインストールしましょう。
brew install nodebrew
インストールしたらnodebrewをパスに設定しましょう。以下コマンドで設定できます。
echo "export PATH=$HOME/.nodebrew/current/bin:$PATH" >> ~/.bash_profile
source ~/.bash_profile
which nodebrew
nodebrewまでのパスが表示されれば成功です。

nodebrewのセットアップをします。
nodebrew setup
nodebrewでインストール可能なバージョン一覧を取得し、安定版をインストールします。
nodebrew ls-all
nodebrew install-binary stable
以下コマンドで使用するnodeバージョンを指定します。
nodebrew use stable
終わりです。nodeとnpmのバージョンを確認しましょう。
node -v
npm -v