nodebrewでNode.jsをインストールしてHello World

nodebrewのインストール

インストール

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

bash_profileにPATHを追加

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

$ source .bash_profile

Node.jsのインストール

7.9.0をインストール

$ MAKE_OPTS="-j 2" nodebrew install-binary v7.9.0

無事インストールできました。

$ nodebrew use 7.9.0
use v7.9.0
$ node -v
v7.9.0

Hello World

ディレクトリを作ってinit。

$ mkdir ~/hello-node-js/
$ mkdir ~/hello-node-js/
$ cd ~/hello-node-js/
$ npm init -y

app.jsを直下に作成

'use strict';

function main(){
   console.log('Hello Node.js!');
}

main();

実行。

$ node app.js
Hello Node.js!

参考