Я установил узел по следующей статье https://github.com/ry/node/wiki/Building-node.js-on-Cygwin-%28Windows%29делает сервер в node.js простого привет мир
Теперь я сделал файл test.js в C: /cygwin/home/adminstrator/test.js здесь папка моего узла настоящее.
Мой test.js файл
var sys = require("sys"),
http = require("http");
http.createServer(function(request, response) {
response.sendHeader(200, {"Content-Type": "text/html"});
response.write("Hello World!");
response.close();
}).listen(8080);
sys.puts("Server running at http://localhost:8080/");
Но в браузере при запуске Localhost: 8080 или 8.8.8.8:8080 содержание не отображающее ("привет мир")
Пожалуйста, укажите, что должно я делаю ?
Редактировать Ошибки при запуске команды
$ node /home/Administrator/test.js
Server running at http://localhost:8080/
/home/Administrator/test.js:5
response.sendHeader(200, {"Content-Type": "text/html"});
^
TypeError: Object #<a ServerResponse> has no method 'sendHeader'
at Server.<anonymous> (/home/Administrator/test.js:5:15)
at Server.emit (events.js:27:15)
at HTTPParser.onIncoming (http.js:871:14)
at HTTPParser.onHeadersComplete (http.js:88:31)
at Stream.ondata (http.js:792:22)
at Stream._onReadable (net.js:762:27)
at IOWatcher.onReadable [as callback] (net.js:276:10)
Вы начали Node.js с помощью 'узла/дома/Adminstrator/test.js' команду из Cygwin консоли? – actual
@actual, если я делаю node test.js, он показывает вывод функции sys.puts («Output»). но как запустить в браузере respose.write? – XMen