1.安装依赖:
sudo apt-get install g++ curl libssl-dev apache2-utils sudo apt-get install git-core
2.下载node.js,0.6.x为node.js的稳定版;
wget http://nodejs.org/dist/v0.6.1/node-v0.6.1.tar.gz
3.解压执行初始化;
tar zxvf node-v0.6.1.tar.gz cd node-v0.6.1 ./configure
4.编译;
make make install
5.验证安装;
node -v
6.例子;
(1)编写测试用例,test.js;
View Code
varhttp = require('http');http.createServer(function(req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello Node.jsn');}).listen(8124, "127.0.0.1");console.log('Server running at http://127.0.0.1:8124/');
(2)在浏览器中验证;
7.安装coffeeScript;
npm install --global coffee-script
8.验证安装:
coffee -v
9.配置coffeescript环境变量:
export NODE_PATH=/usr/lib/node_modules。
NODE_PATH的值可以使用一下命令获取:
npm ls -g
配置node和coffeescript的关联
$ node> require('coffee-script')
OVER