LoginSignup
30
30

More than 5 years have passed since last update.

【node.js】nodebrewでnode.jsのインストールめも

Posted at

node.jsのメリットって大きく2つかな。
・スケーラビリティーの高いアプリケーションを構築ができる
・何万の同時アクセスができる
勉強のためにさくっと構築したのでそのめもを残しました。
これでnode.jsもバージョン管理が簡単にできますね。

nodeが既にインストールされているか確認

% node
% node -v
% which node

上記のコマンドで反応があったらnodeが既にインストールされているのでアンインストールする

既にnode.jsがインストールされている場合は削除する

・brewでインストールした場合はbrewでアンインストール

% brew uninstall node

・node.jsのアンインストールスクリプト

curl -ks https://gist.github.com/nicerobot/2697848/raw/uninstall-node.sh | bash

参考 : https://gist.github.com/nicerobot/2697848
・上記でできなかった場合物理削除

rm -rf /usr/local/lib/node \
/usr/local/lib/node_modules \
/var/db/receipts/org.nodejs.*

nodebrewをインストール

・まず本家のサイトを参考
・nodebrewインストール

% curl -L git.io/nodebrew | perl - setup

・パス追加も忘れずに

vim ~/.bash_profile
export PATH=$HOME/.nodebrew/current/bin:$PATH

筆者のログインシェルはzshなのでzshrcに追加しました。
・インストールするnodeのバージョン確認

% nodebrew ls-all
remote:
v0.0.1 v0.0.2 v0.0.3 v0.0.4 v0.0.5 v0.0.6
......

・バージョンを指定してインストールもできるけど、今回はstableバージョンをインストールする

% nodebrew install stable

現時点でのstableバージョンがv0.10.29でした。
・利用するバージョンを選択

% nodebrew use v0.10.29
use v0.10.29

・インストール確認

% node -v
v0.10.29

30
30
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
30
30