coffee-script をインストールする前に node.js をインストールする必要があります。
node.js は homebrew
を使ってインストールしました。
brew install nodejs
==> Downloading http://nodejs.org/dist/v0.8.8/node-v0.8.8.tar.gz
######################################################################## 100.0%
==> ./configure --prefix=/usr/local/Cellar/node/0.8.8
==> 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
==> Summary
/usr/local/Cellar/node/0.8.8: 846 files, 13M, built in 2.8 minutes
node.js が無事インストールできました。
% which npm
/usr/local/bin/npm
npm
は /usr/local/bin/npm
にインストールされています。
次は coffee-script のインストールです。
こちらは npm
を使ってインストールを行います。
% npm install coffee-script -g
npm http GET https://registry.npmjs.org/coffee-script
npm http 304 https://registry.npmjs.org/coffee-script
/usr/local/share/npm/bin/coffee -> /usr/local/share/npm/lib/node_modules/coffee-script/bin/coffee
/usr/local/share/npm/bin/cake -> /usr/local/share/npm/lib/node_modules/coffee-script/bin/cake
[email protected] /usr/local/share/npm/lib/node_modules/coffee-script
アンインストールする場合には
% npm uninstall coffee-script
とします。
/usr/local/share/npm/bin
にパスを通します。
私は zsh を使っているので.zshrc
で PATH を変更しました。
export PATH=$PATH:/usr/local/share/npm/bin
/etc/paths
に /usr/local/share/npm/bin
を追加してもよいです。
% coffee
coffee> console.log "Hello World"
Hello World
undifined
% cat -n hello.coffee
1 hello = ->
2 console.log("hello world")
3 hello()
% coffee -c hello.coffee
% cat -n hello.js
1 // Generated by CoffeeScript 1.3.3
2 (function() {
3 var hello;
4
5 hello = function() {
6 return console.log("hello world");
7 };
8
9 hello();
10
11 }).call(this);
% node hello.js
hello world
問題なくインストールできました。
ありがとうございます!!! ^_^