创建:
var hello = require(’./hello’);
hello.world();
连接接口:
function Hello() {
var name;
this.setName = function(thyName) {
name = thyName;
};
this.sayHello = function() {
console.log('Hello ’ + name);
};
};
module.exports = Hello;
获取这个对象:
var Hello = require(’./hello’);
hello = new Hello();
hello.setName(‘BYVoid’);
hello.sayHello();
模块放在那里:
var http = require(“http”)
http.createServer(…);