LoginSignup
16
10

More than 3 years have passed since last update.

nodenvでnodeのバージョン管理をする

Posted at

brew で nodenv インストール

$ brew install nodenv

~/.bash_profile なり ~/.zshrc に以下追記

~/.zshrc
# nodenv
[[ -d ~/.nodenv  ]] && \
  export PATH=${HOME}/.nodenv/bin:${PATH} && \
  eval "$(nodenv init -)"

設定反映

$ source ~/.bash_profile

or

$ source ~/.zshrc

nodenv にパスが通ったことを確認

$ nodenv -v      
nodenv 1.3.2

nodenv でインストール可能なバージョン確認

$ nodenv install -l     
0.1.14
0.1.15
0.1.16
.
.
.

※欲しいバージョンがなかったら $ brew upgrade nodenv node-build でアップデートする

お好みのバージョンインストール

$ nodenv install 10.16.0

リフレッシュ

$ nodenv rehash

インストールしたバージョンを使うよう設定

$ nodenv global 10.16.0

指定したバージョンが有効になったことを確認

$ nodenv versions           
  system
* 10.16.0 (set by /Users/mishiwata1015/.nodenv/version)
$ node -v
v10.16.0

$ which node
/Users/mishiwata1015/.nodenv/shims/node
16
10
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
16
10