nodebrew は .node-versionを参照してバージョンを自動で切り替える機能が無いので、
ndenvを切り替えました。
メリット
direnvでnodebrewが入っている場合は、特定のバージョンを使うように強制
しても良かったのですが
-
.node-versionを指定しておくと勝手にそのバージョンを使用 -
anyenvで管理可能 -
anyenvを使っていなくてもI/F自体はほぼrbenvと同様
というメリットが合ったので変更しました
ndenvのインストール
brew install ndenv
echo 'export PATH="${HOME}/.ndenv/bin:${PATH}"' >> <your rc file>
echo 'eval "$(ndenv init -)" >> <your rc file>
exec $SHELL -l
node-buildのインストール
I recommend using node-build for installing node itself. See also node-build.
とあるのでnode-buildもインストールします
git clone https://github.com/riywo/node-build.git $(ndenv root)/plugins/node-build
※$(NDENV_ROOT)/plugins/*/bin配下にインストールする必要があります。(こちら)
homebrewでインストールしてsymlink貼っても良さそうですが、とりあえず簡単な git cloneで
nodebrew環境のアンインストール
パスの削除
rcファイルに↓があるはずなので削除します
export PATH=$HOME/.nodebrew/current/bin:$PATH
export PATH=$HOME/.nodebrew/current/bin/npm:$PATH
nodebrew関連の削除
-
brew uninstall nodebrewでnodebrewを削除します - ~/.nodebrew ディレクトリを削除します