问题node.js require.paths.unshift()

我是新的node.js世界,我使用node.js v0.8.4。 我GOOGLE了这个问题。 是的,我得到了这个解决scheme,但仍然不能理解为初学者。 所以请帮助我……

我正在通过一个node.js教程。 在那篇教程中,使用了node.js v0.1.103,他写道

require.paths.unshift(__dirname+'/vendor'); var http = require('http'), sys = require('sys'), nodeStatic = require('node-static/lib/node-static'); var server = http.createServer(function(request, response) { var file = new nodeStatic.Server('./public', function() { cache: false }); request.addListener('end', function() { file.server(request, response); }); }).listen(8000); 

上面的脚本为他工作。 当我编写示例脚本并运行时,出现此错误。

 C:\Documents and Settings\local>node C:\xampp\htdocs\rt\node\livestats\ server.js Error: require.paths is removed. Use node_modules folders, or the NODE_PATH envi ronment variable instead. at Function.Module._compile.Object.defineProperty.get (module.js:386:11) at Object.<anonymous> (C:\xampp\htdocs\rt\node\livestats\server.js:2:8) at Module._compile (module.js:449:26) at Object.Module._extensions..js (module.js:467:10) at Module.load (module.js:356:32) at Function.Module._load (module.js:312:12) at Module.runMain (module.js:492:10) at process.startup.processNextTick.process._tickCallback (node.js:244:9) 

如何使节点从custome目录加载文件,以及如何解决这个问题? 我的操作系统是windows

谢谢……

require.paths很久以前就被弃用了。 现在,节点v0.1的教程几乎没有任何用处,因为几乎所有的东西都改变了。

如果你使用npm install安装node-static ,你可以直接使用require("node-static")而不指定整个path(当然也可以不使用require.paths )。