Hello World in NodeJS

Node.js is an event-driven I/O server-side JavaScript environment based on V8 the JavaScript engine used in Google Chrome. It is intended for writing scalable network programs such as web servers. It was created by Ryan Dahl in 2009, and its growth is sponsored by Joyent, which employs Dahl (extracted from Wikipedia definition...).

Examples

Launch the nodejs interpreter typing:

~# nodejs
> 

at prompt ">" type:

> console.log("Hello");   
Hello                                                                           

Now we are ready to try the first nodejs example from its web site http://nodejs.org.

web1.js

This is an example of minimal web server written in Node that responds with a "Hello World" message to every web request.

Install the playground directory with all the code examples available on this site following this article: Programming examples on GitHub.

Then move into playground directory and type:

~# cd playground 
~/playground# cd nodejs
~/playground/nodejs# nodejs web1.js
Server web running on board

Open a web browser and access to board URL on: http://fox_ip_address:81 to get the message "Hello World";

Related Links