Thursday, May 7, 2015

How To Write My First Code In Node.js





You truly don't have to set up your own particular surroundings to begin learning Node.js. Reason is extremely straightforward, we as of now have set up Node.js environment on the web, so you can execute all the accessible illustrations online in the meantime when you are doing your hypothesis work. This issues you trust in what you are perusing and to check the outcome with diverse choices

Write this code on your Terminal and press Enter You get Output "Hello World !"

                         // Hello World! program in Node.js 
                              console.log("Hello World!");
 
 
 
 
 
 

 

Neighborhood Environment Setup 

On the off chance that you are as yet willing to situated up your surroundings for Node.js, you require the accompanying two virtual products accessible on your PC,  with these as given follow :
1. Text Editor 
2. The Node.js parallel installables.


This will be utilized to sort your system. Illustrations of couple of editors incorporate Windows Notepad, OS Edit order, Brief, Epsilon, EMACS, and vim or vi.

Name and variant of word processor can fluctuate on diverse working frameworks. For instance, Notepad will be utilized on Windows, and vim or vi can be utilized on windows and Linux or UNIX.

The records you make with your supervisor are called source documents and contain project source code. The source records for Node.js projects are normally named with the augmentation ".js".

Before beginning your programming, verify you have one content tool set up and you have enough experience to compose a PC project, spare it in a record, lastly execute it.


Download Node.js archive

Download latest version of Node.js installable archive file from Node.js Downloads. At the time of writing this tutorial, following are the versions


available on different OS.



Windows




node-v0.12.0-x64.msi
Linux




node-v0.12.0-linux-x86.tar.gz
Mac




node-v0.12.0-darwin-x86.tar.gz
SunOS




node-v0.12.0-sunos-x86.tar.gz





Installation on UNIX/Linux/Mac OS X, and SunOS


Based on your OS architecture, donwload and extract the archive node-v0.12.0-osname.tar.gz into /tmp, and then finally move extracted files into /usr/local/nodejs directory. For example:



$ cd /tmp
$ wget http://nodejs.org/dist/v0.12.0/node-v0.12.0-linux-x64.tar.gz
$ tar xvfz node-v0.12.0-linux-x64.tar.gz
$ mkdir -p /usr/local/nodejs
$ mv node-v0.12.0-linux-x64/* /usr/local/nodejs
 
 
Add /usr/local/nodejs/bin to the PATH environment variable. 


OSOutput
Linuxexport PATH=$PATH:/usr/local/nodejs/bin
Macexport PATH=$PATH:/usr/local/nodejs/bin
FreeBSDexport PATH=$PATH:/usr/local/nodejs/bin

 

Installation on Windows

Use the MSI file and follow the prompts to install the Node.js. By default, the installer uses the Node.js distribution in C:\Program Files\nodejs. The installer should set the C:\Program Files\nodejs\bin directory in window's PATH environment variable. Restart any open command prompts for the change to take effect.


Verify installation: Executing a File

Create a js file named main.js on your machine (Windows or Linux) having the following code.



                         // Hello World! program in Node.js 
                              console.log("Hello World!");


 Now execute main.js file using Node.js interpreter to see the result:


                                  $ node main.js
 
 
If everything is fine with your installation, this should produce the following result:


                                  Hello, World!


 
 
 


1 comment:


  1. Thank a lot for this post that was very interesting. Keep posting like those amazing posts, this is really awesome :) Really the post is very unique.every concepts are captured nice.
    oracle training in chennai

    oracle training institute in chennai

    oracle training in bangalore

    oracle training in hyderabad

    oracle training

    hadoop training in chennai

    hadoop training in bangalore


    ReplyDelete