nodejs

require方法接受以下几种参数的传递:

    - http、fs、path等,原生模块。
    - ./mod或../mod,相对路径的文件模块。
    - /pathtomodule/mod,绝对路径的文件模块。
    - mod,非原生模块的文件模块。
 
创建服务器http服务器也是调用的一个原生模块-http:
var http = require('http');

http.createServer(function (request, response) {
  response.writeHead(200, {'Content-Type': 'text/plain'});
  response.end('Hello World\n');
}).listen(8888);

console.log('Server running at http://127.0.0.1:8888/');
启动node
posted @ 2015-06-11 11:10  心胸广阔  阅读(107)  评论(0编辑  收藏  举报