LoginSignup
7
9

More than 5 years have passed since last update.

Macのnodebrewで入れたnode, npmをクリーンアップ

Posted at

nodeの環境がぐちゃぐちゃになってたので一旦綺麗にしようと思い、
以下その手順です。

まず、npmのuninstall

sudo npm uninstall npm -g

node.jsのuninstall

brew経由でインストールしたnodeのアンインストールです。

brew uninstall node

以下のエラーが出た場合は、
素直に言われた通りにする。

Error: Refusing to uninstall /usr/local/Cellar/node/11.6.0
because it is required by yarn, which is currently installed.
You can override this and force removal with:
  brew uninstall --ignore-dependencies node

言われた通りに以下を実行します。

brew uninstall --ignore-dependencies node

それでもなんか言われた場合。


Uninstalling /usr/local/Cellar/node/11.6.0... (3,938 files, 49.8MB)
node 8.1.3 is still installed.
Remove all versions with `brew uninstall --force node`.

言われた通り以下実行します。

brew uninstall --force node

これでタブを新しく立ち上げて、
nodeとzpmがcommand not foundになったら無事uninstall完了です

node -v
zsh: command not found: node

npm
zsh: command not found: npm

周辺ファイルの削除


sudo rm -rf ~/.npm
rm -rf ~/node_modules

nodebrew経由でinstallし直す

nodebrew setup

パスがない場合は言われた通りにパスを設定してください。

Fetching nodebrew...
Installed nodebrew in $HOME/.nodebrew
========================================
Export a path to nodebrew:
export PATH=$HOME/.nodebrew/current/bin:$PATH
========================================

安定版のnodeをinstall

nodebrew install-binary stable

確認

nodeとnpmコマンドが再び使えるようになっていればokです。

node -v
v10.15.3
npm -v
6.4.1
7
9
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
7
9