app.js
var http = require('http');
http.createServer(function (req, res) {
require("./handle.js").sayHello();
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/');
handle.js
module.exports.sayHello=function(){
console.log(" HEEEEEEloo");
;
node app 启动以后,访问 http://127.0.0.1:1337/ 控制台有输出 如果修改handle.js 以后,必须要重启动node app require 只有第一次加载的时候会读文件 nodejs应该是动态脚本,能不能做到象php那样,require的脚本修改了代码能自动生效 ?