LoginSignup
1
0

More than 3 years have passed since last update.

nodebrewによるNode.jsのインストールとバージョン管理

Last updated at Posted at 2020-02-17

概要

ローカル環境がごちゃごちゃしていたので一度全てアンインストールしてので再インストールした記録。

環境

macOS Catalina 10.15.3
zsh(bashを使用している場合は「.zshrc」を「.bashrc」に読み替えられる。)
homebrew

手順

1.Node.jsの確認とnodebrewのインストール

$ node -v # nodeの存在の確認 #バージョンが表示されたら先にアンインストールする。
  command not found: node

$ brew install nodebrew # nodebrewのインストール

$ nodebrew -v # nodebrewインストールの確認
  nodebrew 1.0.1

2.PATHの設定

$ nodebrew setup # PATHの部分をコピー
Fetching nodebrew...
Installed nodebrew in $HOME/.nodebrew

========================================
Export a path to nodebrew:

export PATH=$HOME/.nodebrew/current/bin:$PATH # <=ここをコピー
========================================

$ echo '# nodebrew' >> ~/.zshrc \ # PATHを通す
$ echo 'さっきのコピーを貼り付け' >> ~/.zshrc \
$ #例) echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.zshrc \

$ vim .zshrc # PATHの確認。「:q」でvimを終了。
# nodebrew
export PATH=$HOME/.nodebrew/current/bin:$PATH

3.Node.jsのインストール

$ nodebrew install-binary stable # Node.js安定版(stable)のインストール。

$ nodebrew list # インストールの確認
v13.8.0
v12.16.0
current: none

$ nodebrew use 12.16.0 # バージョンの変更。複数ある場合はインストール時に表示されたバージョン。
use v12.16.0

$ nodebrew ls # 使用バージョン(current)の確認。
v12.16.0
v13.8.0
current: v12.16.0

$ node -v # バージョン確認
v12.16.0

$ npm -v # node.jsと一緒にインストールされるパッケージ管理ツール。
6.13.4

4.使用しないバージョンのアンインストール(任意)

$ brew uninstall 13.8.0 # アンインストール
v13.8.0 uninstalled

$ nodebrew ls # アンインストール確認。
v12.16.0
current: v12.16.0

参考

【2018年版】macのhomebrewでnodebrew入れてからnode.jsを入れるまで
NodebrewでNodeをインストールする

1
0
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
1
0