我在 Android 上运行 node.js v0.11(通过https://github.com/paddybyers/node)。我试图尝试在这里找到的“Hello HTTP”示例:http: //howtonode.org/hello-node,但是,我遇到了问题。
服务器启动正常,但只要我尝试连接到 http 服务器(通过访问http://localhost:8000/
),我就会收到此错误:
net.js:1156
COUNTER_NET_SERVER_CONNECTION(socket);
^
ReferenceError: COUNTER_NET_SERVER_CONNECTION is not defined
at TCP.onconnection (net.js:1156:3)
我的代码与 Hello HTTP 示例完全相同:
//Load the http module to create an http server.
var http = require('http');
// Configure our HTTP server to respond with Hello World to all requests.
var server = http.createServer(function (request, response) {
response.writeHead(200, {"Content-Type": "text/plain"});
response.end("Hello World\n");
});
// Listen on port 8000, IP defaults to 127.0.0.1
server.listen(8000);
// Put a friendly message on the terminal
console.log("Server running at http://127.0.0.1:8000/");
我怎样才能解决这个问题?
谢谢!