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 a module that is a predefined set of function to simplify the creation of complex application as we have libraries in C language. Each module contains 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 modules as well. To use a predefined module we use “require ()” function  ,for eg
  1. 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 the fs variable.
 
NPM
 
Npm refers to the node package manager, it  publish, manage, and Installs node programs.
 
Eg: 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 the cd to go the move to the location of the file and we are done with the Hello World Now.