LeavingMe.net

nodejs

2011-04-24 23:42:00

安装手册

https://github.com/joyent/node/wiki/Installation

Ubuntu 10.10 安装 nodejs

sudo apt-get install python-software-properties
sudo add-apt-repository ppa:jerome-etienne/neoip
sudo apt-get update
sudo apt-get install nodejs

安装完后查看版本号

node -v
v0.4.7

Hello World

var http = require('http');
http.createServer(function (req, res) {
  res.writeHead(200, {'Content-Type': 'text/plain'});
  res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
node example.js
Server running at http://127.0.0.1:1337/
comments powered by Disqus