1. 程式人生 > >node項目中用到的一些模塊

node項目中用到的一些模塊

模塊 代碼 require write creates http模塊 function var cnblogs

1、http模塊,用來搭建服務器

代碼,簡單服務器實現

1 var http = require(http);
2 http.createServer(function (request, response) {
3   response.writeHead(200, {"Content-Type": "text/plain"});
4   response.write(hello word);
5   response.end();
6 }).listen(8888)

2、url模塊,處理url路徑的值

3、querystring模塊,處理字符串

參考文章:http://www.jianshu.com/p/aed6a885db61

4、fs模塊,處理文件

參考文章:http://www.jianshu.com/p/5683c8a93511

node項目中用到的一些模塊