久しぶりにndenvに新しいNode.jsのバージョンをインストールしようと思ったら使い方を忘れてて、ndenvのサイトにアクセスしたら、こんな記述が。
[Deprecated] nodenv is better alternative
Please consider to use nodenv. ndenv repository is not maintained actively.
もう、ndenvは廃止予定でnodenvに移行しなさいとのこと。
いつの間にかndenvが時代遅れになってしまいました。
なので、nodenvを使えるようにしたいと思います。
ndenvを Homebrew でアンインストールします。
$ brew uninstall ndenv
nodenvをインストールします。Homebrew でインストールできるので簡単ですね。
$ brew install nodenv
次に、nodenvの初期化を行います。
$ nodenv init # Load nodenv automatically by appending # the following to ~/.bash_profile:
~/.bash_profileに設定を追加しろとメッセージが出たので従います。設定後、bash の設定を再読み込みします。
$ echo 'eval "$(nodenv init -)"' >> ~/.bash_profile $ source ~/.bash_profile
これで基本的に設定は終わりなのですが、インストールがちゃんとできたかチェックするスクリプトがあるので実行しておきます。
$ curl -fsSL https://github.com/nodenv/nodenv-installer/raw/master/bin/nodenv-doctor | bash Checking for `nodenv' in PATH: /usr/local/bin/nodenv Checking for nodenv shims in PATH: OK Checking `nodenv install' support: /usr/local/bin/nodenv-install (node-build 4.6.1) Counting installed Node versions: none There aren't any Node versions installed under `/Users/xxxxx/.nodenv/versions'. You can install Node versions like so: nodenv install 2.2.4 Auditing installed plugins: OK
問題ないですね。
Node.jsの新しいバージョンをインストールします。
インストール可能なNode.jsのバージョンをリストに出力します。
$ nodenv install -l ︙ 12.1.0 12.2.0 12.3.0 12.3.1 12.4.0 ︙
今回は、バージョン12.0.0以上をインストールしたいので、12.4.0をインストールします。
$ nodenv install 12.4.0
この段階では、まだ 12.4.0 は有効になっていないので、下記コマンドで 12.4.0 を有効にします。
$ nodenv global 12.4.0
Node.jsのバージョンを確認します。
$ node -v v12.4.0
正しく設定されていますね。
nodenvはndenv と使い方もあまりかわらないようですし、インストールさえできれば簡単に移行できそうです。