我试图运行一个示例服务器,但在Windows上收到错误消息。然后我试图在我的朋友的机器上运行它,但它也很顺利,windows系统也一样。我不知道发生了什么事。 让我带源代码和错误消息: 源代码:nodejs error:module.js:340 throw err;
var http = require("http");
http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.write("Hello World");
response.end();
}).listen(8888);
输出:
D:\test>node server.js
module.js:340
throw err;
^
Error: Cannot find module 'D:\test\server.js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
PS:server.js是要执行的文件。
检查是否'server.js'是要执行的文件的名称。你提到它是错误的。 – mithunsatheesh 2014-09-23 07:07:47
@mithunsatheesh抱歉,** server.js **是我正在执行的文件。 – mts 2014-09-23 07:14:18
您的server.js不在测试文件夹中 – mithunsatheesh 2014-09-23 07:23:22