LoginSignup
6
7

More than 5 years have passed since last update.

CoffeeScript開発環境構築メモ

Posted at

Mountain LionにCoffeeScriptの環境を構築したのでメモしておきます。

インストール

node.jsのインストール
brew install node.js
確認
node -v
v0.8.15
npmのインストール
curl https://npmjs.org/install.sh | sudo sh
CoffeeScriptのインストール
sudo npm install -g coffee-script
確認
coffee -v
CoffeeScript version 1.4.0

動作テスト

テストディレクトリの作成
cd ~/
mkdir js_dir (JavaScript格納ディレクトリ)
mkdir coffee_dir (CoffeeScript格納ディレクトリ)
ディレクトリは適宜移動します。
sample.coffeeの作成

下記の内容を追加

helloworld = 
-> console.log "hello world"

helloworld()
実行
coffee sample.coffee
helloworld

JavaScriptへのコンパイル
coffee -o <出力先ディレクトリ> -c <ソースディレクトリ>
coffee -o js_dir/ -c coffee_dir/
内容の確認
/ Generated by CoffeeScript 1.4.0
(function() {
  var helloworld;

  helloworld = function() {
    return console.log("hello world");
  };

  helloworld();

}).call(this);

参考URL

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