LoginSignup
6
8

More than 5 years have passed since last update.

macへのnodebrewを使ったnode.jsの5分間インストール

Last updated at Posted at 2018-04-25

5分間インストール

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • nodebrew をインストールする
brew install nodebrew
# インストールされたことを確認する
nodebrew -v
  • nodebrew をセットアップする
nodebrew setup
  • インストールできる node.js のバージョンを確認する
nodebrew ls-remote
  • node.js の最新版をインストールする
nodebrew install-binary latest
# インストールされたバージョンを確認する
nodebrew list
  • node.js をバージョンを指定してインストールする
nodebrew install-binary 10.0.0
# インストールされたことを確認する
nodebrew list
  • 使用する node.js のバージョンを設定する
nodebrew use v10.0.0
# 設定されたことを確認する
nodebrew list
  • コマンドへのPathを通す
# .bash_profile に exportを追記する
echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.bash_profile
# 設定を反映する
source ~/.bash_profile
# 設定を確認する
printenv PATH
  • コマンドが使えることを確認する
node -v
npm -v

バージョンが確認できればインストール完了です。

補足 : 異なるバージョンをインストールしてバージョンを変更する

  • インストールできる node.js のバージョンを確認する
nodebrew ls-remote
  • node.js をバージョンを指定してインストールする
nodebrew install-binary 6.0.0
# インストールされたことを確認する
nodebrew list
  • 使用する node.js のバージョンを設定する
nodebrew use v10.0.0
# 設定されたことを確認する
nodebrew list
  • コマンドが使えることを確認する
node -v
npm -v
6
8
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
6
8