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
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.
- Open Notepad and Write Console.log('Hello
node.js Developers!! we are gonna learn node.js right from the basics.');
- save the file as hello.js
- Open node.js command prompt
- type node hello.js and press Enter
I used the cd to go the move to the location of
the file and we are done with the Hello World Now.