LoginSignup
144
126

More than 5 years have passed since last update.

【Mac版】node.jsのアンインストールと再インストール手順メモ

Posted at

目的

  • いま入っているnode.jsを綺麗にしたい!nodebrewでバージョン管理をしたい!と思ったときにコマンド叩くだけで再現できるようにメモ

1. Node.jsをアンインストールする

1-1. npmをアンインストール

$ npm uninstall -g npm
$ rm -rf .npm \
>    node_modules

1-2. nodeをアンインストール

パッケージ(pkg)版の場合
homebrewを使っている場合
$ brew uninstall node
その他
$ lsbom -f -l -s -pf /var/db/receipts/org.nodejs.node.pkg.bom \
> | while read i; do
>  sudo rm /usr/local/${i}
> done
$ sudo rm -rf /usr/local/lib/node \
>     /usr/local/lib/node_modules \
>     /var/db/receipts/org.nodejs.*
ソース版の場合

node実行ファイルの存在場所を確認し、ファイル削除。

$ which node
/usr/local/bin/node
$ rm -rf /usr/local/bin/node \
>     node_modules

2. Node.jsを再インストールする

2-1. nodebrewをインストールして環境変数を設定する

$ curl -L git.io/nodebrew | perl - setup
$ export PATH=$HOME/.nodebrew/current/bin:$PATH

2-2. nodeをインストール

バージョン指定
$ nodebrew install-binary v{使いたいバージョン}
最新版
$ nodebrew install-binary latest

2-3. インストールしたバージョンの確認

$ nodebrew ls
v11.10.1

current: none

2-4. バージョンを設定

$ nodebrew use v{使いたいバージョン}

2-5. 動作確認

$ node -v
v11.10.1

参考

144
126
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
144
126