7
4

More than 5 years have passed since last update.

MacOSにNodeインストールでハマったポイント

Posted at

はじめに

Mac初心者がNode.js入れる際に試行錯誤したときのメモなので中級者の方は閲覧注意 :sweat_drops:

確認

Reactを使うためNode.jsをMacにインストールすることになったので、とりあえず確認。

$ node -v
v4.5.0

ファッQ?いやいや、入れてないし、、しかも古い。
ちなみにMac環境はOS X Yosemite 10.10.5(これも古くてすいません。。。 :bow:

削除

とりあえず消します。
qiita_up.png

出てきた結果
MacOS XからNode.jsをアンインストールする方法

再確認

$ node -v
v4.5.0

えっ???消えてない。。。

$ which node
/usr/local/bin/node

発見 :bulb: ってことで再削除
$ rm -rf /usr/local/bin/node

nodebrewインストール

ここからは結構簡単でした^^

$ brew install nodebrew

~/.bash_profile(zshなら~/.zshrc)に以下を追加
export PATH=$HOME/.nodebrew/current/bin:$PATH

ターミナル再起動 or 下記コマンド実行
$ source ~/.bash_profile

確認
$ nodebrew help

Node.jsインストール

インストールできるNode.jsのversionを確認します。
$ nodebrew ls-remote

今回はv6.5.0をインストールします。
$ nodebrew install-binary v6.5.0

おやっ??

Fetching: https://nodejs.org/dist/v6.5.0/node-v6.5.0-darwin-x64.tar.gz
Warning: Failed to create the file 
Warning: /Users/fukufuku/.nodebrew/src/v6.5.0/node-v6.5.0-darwin-x64.tar.gz: No 
Warning: such file or directory
curl: (23) Failed writing body (0 != 941)
download failed: https://nodejs.org/dist/v6.5.0/node-v6.5.0-darwin-x64.tar.gz

って感じで怒られたのでググります。。。
nodebrew install がFailed to create the fileと怒られる

とりあえず無いディレクトリを作成します。
$ mkdir -p ~/.nodebrew/src

もう一度インストールしてみます。

$ nodebrew install-binary v6.5.0
...
Installed successfully

成功したみたいなので確認

$ nodebrew ls
V6.5.0

使いたいバージョンを指定します。

$ nodebrew use v6.5.0
use v6.5.0

確認

$ node -v
v6.5.0

幸せ :heart_decoration:

7
4
1

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
4