Node js tutorial | node js

nodejs

What’s Node.js?

Node.js is an open source cross-platform runtime environment for executing javascript code outside of a browser(on a server). In simpler language, JavaScript is a client-side programming language, which means its code is executed in the browser. But now using Node.Js, JavaScript can also be executed on the server.

Node.js is built on Chrome’s V8 JavaScript engine.

Note: Node.Js and node are basically the same. It’s just dummy naming. In this post, we’ll use it interchangeably.

It is an asynchronous event-driven JavaScript runtime, which means it is ideal for building superfast, highly-scalable, data-intensive real-time applications. We often use node to build backend services an APIs.

What’s so special about node?

  • It’s easy to get started
  • Great for agile development
  • Lightweight
  • East and cheap hosting
  • Speedy and scalable architecture
  • Reuse of codes at every level
  • Real-time web socket programming
  • Uses open source community driven modules
  • Compatibility with Google V8 engine to enhance performance

We can go on the list all day long. With Node.js, you can build a way faster applications, by writing fewer lines of code and faster build time than the traditional.

Enough of the list and let’s talk facts. Node.js is Used in Paypal, Netflix, uber, Walmart and other big companies.

Paypal was one of the first company who was given a chance to use Node.js, to take the risk to make difference.  The below chart shows their findings.

paypal comparison of java and nodejs

 

We can summarize their achievements as:

  • twice as fast with
  • fewer people where used
  • 33% fewer lines of code
  • 2X requests/second
  • 35% faster response time
  • 40% fewer lines of code

Below is a video of why Netflix goes with Node.js

You can follow this post to get detailed comparisons.

Installing Node

Prerequisites

  • U just need to know simple command line usage. Don’t worry if u don’t know though, just follow this post.

What is npm?

Npm is a package manager. It lets you install software (libraries, plugins, frameworks and applications).

From the official npm site, it says

Use npm to install, share, and distribute code and also manage dependencies in your projects.

Installation on Windows

Installing node on Windows is a breeze. Just go to this page, download the Windows version and install it like a normal program.

Installation on Ubuntu 18

Installing the Distro-Stable Version for Ubuntu

First thing first

sudo apt update

Install node from the official repositories

sudo apt install nodejs

then install node package manager npm

sudo apt install npm

then check if you’ve installed both correctly with command

nodejs -v

node -v

and if installed correctly it will show the version number

If you want to install from PPA or for other distros, follow this link

Thanks for reading all along. If you have any questions, I’d be more than happy to answer them.

 

Programming and Design

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: