16
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

node.jsでHello World

Posted at

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と表示されれば成功です。

16
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?