Macにnode.jsとnpmをインストールする

GitHub社が開発したチャットbot開発・実行フレームワークの「Hubot」を使って何か遊んでみようと思い立った。その前にnpmnode.jsが必要だった。

『Hubot』って?
http://gihyo.jp/dev/serial/01/hubot/0001

今回は、node.jsのversion管理をしてくれるツールnodebrewをインストールします。これをインストールするとnpmもインストールされる。

nodebrewをインストール

curlコマンドでインストールする。

$ curl https://raw.githubusercontent.com/hokaccha/nodebrew/master/nodebrew | perl - setup
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 24340 100 24340 0 0 32924 0 --:--:-- --:--:-- --:--:-- 32981
Fetching nodebrew...
Installed nodebrew in $HOME/.nodebrew

========================================
Export a path to nodebrew:

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

パスを通す

ホームディレクトリに.bash_profileを追加する。

$ vi ~/.bash_profile

内容は以下を追加する。

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

設定の反映をする。

$ source ~/.bash_profile

nodebrewを最新版にアップデート

$ nodebrew selfupdate
Fetching nodebrew...
Updated successfully

node.jsのインストール

$ nodebrew install latest

10分以上かかった..

node.jsの最新版を使う

$ nodebrew use latest
use v6.7.0

node.jsのバージョン確認

$ node -v
v6.7.0

npmのバージョン確認

$ npm -v
3.10.3

これでnode.jsとnpmのインストールができた。次回は、Hubotのインストールをする。

参考サイト:
Macにnodebrew(node.js, npm)をインストールする手順

[Sponsored Links]







  • このエントリーをはてなブックマークに追加
[Sponsored Links]