MacでNode.jsの最新版をインストールします。

nodebrewインストール

homebrewでnodebrewをインストールします。

$ brew install nodebrew
$ /usr/local/opt/nodebrew/bin/nodebrew setup_dirs
$ nodebrew -v
nodebrew 1.0.1

nodeの最新版をインストールする

nodebrewを使って最新版のnodejsをインストールします。

$ nodebrew install-binary latest

バージョンを指定したい場合は以下のように指定します。

$ nodebrew ls
$ nodebrew install v10.14.2

インストールしたnodejsにpathが通っていないのでpathを通します。

$ echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.bash_profile
$ . .bash_profile
$ node -v
v10.14.2

終わり。