LoginSignup
236
160

More than 5 years have passed since last update.

NodebrewでNodeをインストールする

Posted at

参考リンク

始める前に

nodeがインストール済みの場合、アンインストールが必要です。

homebrewの場合

brew ls  // nodeが表示されたら、以下のコマンドでアンインストール
brew uninstall --force node

npmの場合

npm ls -g node  // nodeが表示されたら、以下のコマンドでアンインストール
npm uninstall -g npm

Nodebrewをインストールする

  • インストール
    brew install nodebrew

  • 確認
    nodebrew -v
    バージョンが表示されればOK。

  • 環境変数を追加
    vi ~/.bash_profileで、以下を追加する。

export PATH=$HOME/.nodebrew/current/bin:$PATH

bash_profileを更新して設定を反映させる。
source ~/.bash_profile

セットアップ。これやらないとインストールできない。
nodebrew setup

バージョン指定してnodeをインストールする

  • インストール可能なバージョンを確認
    nodebrew ls-remote

  • nodeのインストール
    nodebrew install-binary <version>

    ※ nodebrew installでインストールするとスゴイ時間がかかるので、上記のコマンドが良いらしい。

現時点だとv10.15.0が最新なので、これをインストール
nodebrew install-binary v10.15.0

  • インストールしたバージョンを確認
    nodebrew ls

  • 使いたいバージョンを指定
    nodebrew use v10.15.0

もう一度nodebrew lsを叩いて、currentが指定されてればOK。

  • 最後に node -vでバージョンが表示されれば万事完了!
236
160
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
236
160