New blog domain: kula.blog

It's still work in progress but new posts will be published on  https://kula.blog/ Thanks to 11ty base blog RSS is working from the start so it should be easy to add to your reader if you still use any :) If now then I hope you can sign up to the newsletter where I'll be publishing new posts and interesting articles to it from time to time. Please use  kula.blog  from now on.

Node.js Beginner Introduction

What is Node.js
Short version: JavaScript engine from Chrome with modules for handle files and httpServer.
 http://nodejs.org/


In this post:

  1. Installation
  2. Cloud9 IDE
  3. Hosting
  4. Example


1: Installation
Go to http://nodejs.org/ and decide if You want stable (4.*) version or dev (5.0-pre).
Stable can be downloaded from: http://nodejs.org/#download with tar.gz format.
Dev from github.
Installation:
https://github.com/joyent/node/wiki/Installation
On my ubuntu it was pretty easy, but If You fail to install it, don't give up and check section about Cloud :)

2: Cloud
Sign up for beta at: http://cloud9ide.com/
Cloud9 IDE uses github for

  1. signup - You must have github accout
  2. checkout of project code (creation of new project via pasting github repo url)
Cloud9 IDE has some 'beta' bugs but it is usable now and can be used to develop Node.js applications.
You must be aware that Cloud9 IDE needs some specified values of host and port tu run code properly (more at the bottom).

Pros:
  • git support (command line at the bottom)
  • runs Node.js code (like in Eclipse)
  • ACE code editor
Cons:
  • Without support for npm http://npmjs.org/
  • Without npm we can use only core Node.js, without frameworks
  • I'm not sure but I was unable to find any informations about database (let me now in comments if there is)

3: Hosting:



4: Example


//Cloud9 IDE to run Node.js needs
//to start server at specified host and port
HOST = "0.0.0.0";
PORT = process.env.C9_PORT;

var http = require('http');
http.createServer(function (req, res){
    res.writeHead(200, {'Content-Type':'text/plain'});
    res.end('Hello World\n');
}).listen(PORT, HOST);

console.log('Server running at '+ HOST + ':' + PORT);

The same code from gist:



Comments

Popular posts from this blog

How to simulate slow connection (developer proxy in Node.js)

Safari Mobile CSS VW and VH units bug.