Lab / Node JS

Node.JS basics

I loose lot of time for understand how to work Node.JS and I really don't understand why all the tutorials not speaks about this simple things, because is fucking basics and we most to understand it before the start.

So lets start to understand right now.

Basics:

For testing we'll use simple example, in app.js file paste this code:

var http = require('http');
var server = http.createServer(function(req, res) {
res.writeHead(200, { 'Content-Type': 'text/plain' });
res.end('Hello node.js!');
});
server.listen(3000);

So, every time when you’ll closing a terminal, you app will be stoped (OS X). for use the app again you need to repeat this steps

Tanks for attention.