Node.jsをさわる その1

冬休みの宿題としてNode.jsに触れる。

課題図書は Node.js入門

サーバサイドJavaScript Node.js入門

サーバサイドJavaScript Node.js入門

macにnode.jsをインストールする

昔、brewでいれてた少し古めのnode.jsをunlink

sudo brew unlink node

node.jsをbrewでいれる

sudo brew install node
==> Downloading http://nodejs.org/dist/v0.8.16/node-v0.8.16.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/node/0.8.16
==> make install
==> Caveats
Homebrew installed npm.
We recommend prepending the following path to your PATH environment
variable to have npm-installed binaries picked up:
  /usr/local/share/npm/bin
Warning: Could not link node. Unlinking...
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
You can try again using `brew link node'
==> Summary
/usr/local/Cellar/node/0.8.16: 870 files, 13M, built in 8.7 minutes

npmが既に入ってるエラーがでたので強制的に上書く

sudo brew link node
Linking /usr/local/Cellar/node/0.8.16... Warning: Could not link node. Unlinking...

Error: Could not symlink file: /usr/local/Cellar/node/0.8.16/bin/npm
Target /usr/local/bin/npm already exists. You may need to delete it.
To force the link and delete this file, do:
  brew link --overwrite formula_name

To list all files that would be deleted:
  brew link --overwrite --dry-run formula_name

sudo brew link --overwrite node

バージョン確認

node --version
v0.8.16