Getting Started with node js

7 Feb

Nodejs is now very populer language to develope web applications. it is very fast and light weight and we can create out own http server in nodejs.
if you are familier with javascript then you can start working in nodejs. node js runs on server side. node js file saves with .js extenstion.
In order to develope application in node js you need write javascript code and there are many types of tasks like database connection, file upload redis connectivity, image operations are done in server side app.
you receive post data and save it in the database.

you can do these all kind of tasks in node js and almost everything that is done in a server side app.
In order to do nodejs progamming you can start writing code in js but as you know that every programming language need extenstion,include file or modules to perform specific task. for example in php if you want to do image processing then you have to enable gd module and for database operation you have enable mysql module. In c you have include header files. same like that in nodejs you need to install modules for differente different types of need.

npm node package manager is a repositary where you can find thousands of node modules that you can install through npm.

First you need to install nodejs

> curl -sL | sudo -E bash –
> sudo apt-get install -y nodejs

Alternatively, for Node.js v5:

> curl -sL | sudo -E bash –
> sudo apt-get install -y nodejs

Optional: install build tools

To compile and install native addons from npm you may also need to install build tools:

> sudo apt-get install -y build-essential

after that you can install node package manager (npm)
> apt-get install npm

create a fresh directory
> mkdir mynodeapp

> cd mynodeapp

Crate a file index.js and write below code in the file

> vim index.js
console.log(‘hello world’);

now run it in the command prompt

> node index.js.
hello world

Leave a Reply

Your email address will not be published. Required fields are marked *