NodeJS-#1-Hello World

Persiapan

  1. Installasi NodeJS

Implementasi

Buat project

mkdir learning-hello-world
cd learning-hello-world

Membuat Program Berbasis Teks dengan Nodejs

buat script hello-world.js

console.log("Hello World!");

Simpan lalu jalankan :

node hello-world.js
hello-world.js

Membuat Webserver dengan Nodejs

buat script server.js

var http = require('http');

var server = http.createServer(function (req, res) {
    res.end("Hi, selamat datang di nodejs");
});

server.listen(8000);

console.log("server running on http://localhost:8000");

lalu jalankan

node server.js
server.js

buka web browser buka http://localhost:8000

http://localhost:8000

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>