20
20

More than 5 years have passed since last update.

Mac に nodenv を利用して Node.js をインストールする

Last updated at Posted at 2018-08-04

Mac に nodenv を利用して Go をインストールする手順。

nodenv のインストール

Homebrew でもインストールできるが、 git clone でインストールする。手順は nodenv のドキュメントを参照する。

$ git clone https://github.com/nodenv/nodenv.git ~/.nodenv
$ cd ~/.nodenv && src/configure && make -C src

.bash_profile に下記を追記する。

# nodenv
export PATH="$HOME/.nodenv/bin:$PATH"
eval "$(nodenv init -)"

.bash_profile を読み込む。

$ source .bash_profile

node-build をインストールする

$ git clone https://github.com/nodenv/node-build.git $(nodenv root)/plugins/node-build

nodenv の使い方

インストール可能なバージョンを確認する。

$ nodenv install -l

指定のバージョンをインストールする。

$ nodenv install 8.11.3
$ nodenv rehash

指定のバージョンをグローバルで利用する。

$ nodenv global 8.11.3

指定のバージョンをローカル(そのディレクトリ)で利用する。

$ nodenv local 8.11.3

マシンにインストールされているバージョンを確認する。

$ nodenv versions

nodenv を更新する方法

$ cd $(nodenv root)
$ git pull

node-build を更新する方法

$ cd $(nodenv root)/plugins/node-build
$ git pull
20
20
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
20