简体   繁体   English

node.js-简单的hello world应用程序不起作用

[英]node.js - simple hello world app don't work


I'm trying hard to learn Node.js, but because the lacks of tutorials I having hard time learning it. 我正在努力学习Node.js,但是由于缺少教程,我很难学习它。

So I have the following code - 所以我有以下代码-

var http = require('http');

var server = http.createServer();

http.request(function (req, res) {

    res.writeHead(200);

    res.write("Hello World");

    res.end();
});

server.listen(5000);

So after I compile it, I type in chrome localhost:5000 and crap it does not work.. 因此,在编译之后,我输入chrome localhost:5000并把它废除了。
What I did wrong? 我做错了什么?

take a look at nodejs site 看看nodejs网站

var http = require('http');

http.createServer(function (req, res) {

    res.writeHead(200);

    res.write("Hello World");

    res.end();
});

server.listen(5000);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM