A Hello World Program in Node.js

A hello World program in Node.js
 
Before I Start with hello world there are few terminologies that you should know as we are gonna use it frequently in almost every exercise we are gonna use them.

Modules

Node.js uses module that are predefined set of function to simplify the creation of complex application as we have libraries in C language.Each module contain some set of functions that is related to the theme of the module like for file system we will use “fs” .We can create and publish our own module as well. To use a predefined module we use “require ()” function  ,for eg

var fs = require(‘fs');

The require function returns the reference to the specific module.In this case ,a reference to the fs(file system) module is stored in fs variable.

NPM

Npm refers to node package manager,it  publish,manage and Installs node programs.
Eg : npm npm install [email protected]  to install mysql

Writing your First Application.

  1. Open Notepad and Write Console.log('Hello node.js Developers!! we are gonna learn node.js right from the basics.');

    Image-1.jpg

  2. save the file as hello.js
  3. Open node.js command prompt

    Image-2.jpg

  4. type node hello.js and press Enter

    Image-3.jpg

I used cd to go the move to the location of the file and we are done with the hello World Now.

Ebook Download
View all
Learn
View all