Node.js入门

一)Hello World

var http = require(‘http‘);

http.createServer(function(req,res) {
    res.writeHead(200,{‘Content-Type‘:‘text/plain‘});
    res.end(‘Hello World\n‘);
}).listen(3000,"127.0.0.1");

console.log(‘Server running at http://127.0.0.1:3000/‘);

 

二) Module

npm install 【module_name】  //需要全局安装时加上-g标记

npm search 【module_name】 //搜索模块

npm docs 【module_name】 //查看模块文档

npm bugs  【module_name】 //查看bug

npm eidt【module_name】

可用于搜索模块:

http://blago.dachev.com/modules