LoginSignup
0
3

More than 3 years have passed since last update.

brew doctorした時のWarning['Unbrewed header files']解消とNode.jsをインストール

Last updated at Posted at 2019-06-28

brew doctorしてみるとWarningが出たので解消方法とnodebrewでnode.jsをインストールした議事録です

brew doctorの存在を知り自分のターミナルで実行してみるとまさかのWarningが...
Image from Gyazo

見てみるとnode関連のファイルがエラーを引き起こしている。
"これらのファイルを故意的に置いていないのならhomebrewする時にエラーを起こすかもしれないから消したほうがいいですよ"みたいな解釈。

記憶にないがnodeをhomebrewなしでインストールしたのかもしれない。

解決方法はこの記事にあるように1.放置するか2.消してhomebrewから再インストールするか

自分は今後homebrewでエラーが出てデバッグするのが嫌なので2.消してhomebrewから再インストールするかにします。

とりあえずコマンドこれらをremoveしていきます。

解決方法

sudo rm -r /usr/local/include/node/を打ち込んでターミナルでbrew doctorしてみると
Image from Gyazo
..よかった。

nodebrewをインストール

その前にNode.jsのバージョン管理ツールであるnodebrewをインストールします。

brew install nodebrew

nodebrewはNode.jsのバージョン管理ツールです。
複数のバージョンをインストールし切り替えたりすることができます。
rubyで言うrbenvみたいな感じです。

You need to manually run setup_dirs to create directories required by nodebrew:
  /usr/local/opt/nodebrew/bin/nodebrew setup_dirs

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

To use Homebrew's directories rather than ~/.nodebrew add to your profile:
  export NODEBREW_ROOT=/usr/local/var/nodebrew

Bash completion has been installed to:
  /usr/local/etc/bash_completion.d

zsh completions have been installed to:
  /usr/local/share/zsh/site-functions

インストール出来ました。

次にパスを追加していきます。
上の通りにすれば良さそうです。
$ echo 'export PATH=$HOME/.nodebrew/current/bin:$PATH' >> ~/.bash_profile
$ source ~/.bash_profile

Node.jsをインストール

Image from Gyazo
nodebrew ls-remoteでversionを確認できるみたいですが今回は最新版をインストールします。

nodebrew install latest
Image from Gyazo
エラーが出たのでディレクトリとファイルを作成します。
mkdir -p ~/.nodebrew/src

Image from Gyazo

成功!

以前と比べてコマンド操作の不安もなくなってきて何となくの成長を感じております。
ご覧いただきありがとうございました!

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