Help us understand the problem. What is going on with this article?

node.jsでHello World

More than 3 years have passed since last update.

1.Hello Worldを表示させる

下記のソースを任意のディレクトリで保存します。

ここではexample.jsという名前で作成しました。

var sys = require('sys');
var http = require('http');
var server = http.createServer(
    function (request, response) {
        response.writeHead(200, {'Content-Type': 'text/plain'});
        response.write('Hello World!!');
        response.end();
    }
).listen(3000);
sys.log('Server running at http://localhost:3000/');

2.example.jsを実行

$ node example.js
7 Aug 09:50:00 - Server running at http://localhost:3000/

3.ブラウザからアクセス

ブラウザから以下へアクセス

http://localhost:3000

Hello Worldと表示されれば成功です。

sims0728
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away