blog

Home / DeveloperSection / Blogs / Top 15 Useful Modules

Top 15 Useful Modules

Anchal Kesharwani3068 26-Aug-2014

In this blog, I’m explaining the important modules in node.js. Node.js have a lot of modules contain but there are some necessary modules describe here.

Node.js has been very popular these days because of its non-blocking asynchronous I/O nature. Since node.js is JavaScript on the server side with networking and I/O support many developers and companies are converting their existing system to node.js.

Modules in Node.js

Modules is a simply library file or collection of class or packages as java which when included in the current application provides extra features. So a module is simply an “external piece of independent code which adds additional functionality to the existing structure and application.”

Modules are crucial to building applications in Node, as they allow you to include external libraries, such as database access libraries - and they help in organizing your code into separate parts with limited responsibilities. You should try to identify reusable parts in your own code and turn them into separate modules to reduce the amount of code per file and to make it easier to read and maintain your code.

Using modules is simple: you use the require() function, which takes one argument: the name of a core library or a file system path to the module you want to load. You’ve seen this before in the simple messaging application example, where I used require() to use several core modules.

In this blog, just explaining only few modules which are most important in the node.

1.    Express Module

Express is a module that contain all minimum features of web application framework which gives the robust features to build single and multi-page and hybrid web application easy and fast. Express when installed globally can be very useful in creating projects from the command line.


To install the express module by this command:
   npm install express

To create an express project in node.js.
Syntax:
     express <application-name>

2.   Jade Module

Jade is a tinplating engine for node.js (like smarty template system for php.) It is similar in concept to coffee script.

Jade is default tinplating engine for express framework. Jade is a high performance template engine heavily influenced by Haml and implemented with JavaScript for node. It allows programmers to write more meaningful html.

It can be installed by issuing the following command from command prompt

    npm install jade

3.   Mongoose (A MongoDB npm module)

Mongoose is a driver to interact with MongoDB database management system in node.js. MongoDB database is an open-source document oriented database, and the leading NoSQL database. MongoDB features has many features such as indexing, auto sharding, MapReduce, GridFS, etc. Node.js when combined with MongoDB creates some of the best and fastest modern applications. The Document in MongoDB have JSON structure with support for binary data.

To installed the mongoose by the following command:

    npm install mongoose

4.   MySql Module

Mysql is a driver to interact with Mysql database management system in node.js. To install the mysql module from the following command:

                npm install mysql

5.   Nodemailer Module

Nodemailer is a module provide the facility to send e-mail from your application with Node.js using SMTP. Nodemailer easy to use.


To install the nodemailer module in node.js:
      npm install nodemailer

6.   Nano Module

When your application need to interact with the NoSQL database CouchDB then you may need this module. Nano is minimalistic CouchDB driver for node.js.


To install Nano module in node.js following command;
     npm install nano
7.   Socket.IO Module

Socket.IO module is necessary module in the node.js. Socket.IO aims to make real-time apps possible in every browser and mobile device, blurring the differences between the different transport mechanisms. It’s care-free real-time 100% in JavaScript.

To install the Socket.IO module by the following command:

   npm install socket.io

8.   Stylus Module

Stylus is an expressive, dynamic, robust CSS pre-processor for Node.js. It is similar to Sass.js, Sass or Less.js. Stylus is a revolutionary new language which provides an efficient, dynamic, and expressive way to generate CSS. It has support for both an indented syntax and regular CSS style.

To install the Stylus module in node.js by the following command:

                npm install stylus

9.   Calipso Module

Calipso is a simple CMS (Content Management System) like as Wordpress, Drupal, or Zomla. It is designed to be fast, flexible and simple. It uses MongoDB for database operations. There are following command to install calispo module:

  npm install calipso -g
calipso site /var/www/CMSSite
cd /var/www/CMSSite
calipso server
10.PDFKit Module 

You can generate pdf using the PDFKit module in node.js. We can create pdf using PDFKit using plain old HTML and CSS. In short PDFKit is a PDF document generation library for Node that helps in creating complex, multi-page, printable documents easy. It’s written in CoffeeScript but the API can be called using JavaScript.

       To install PDFKit module by the following command:

             npm install pdfkit

11.Async Module

It is a module to execute many functions one after the other and we keep on passing callback function to it. This module is used for the asynchronous programming.

   To install async module by the following command:           
 npm install async
12.Grunt Module

Sometimes you may need to do a repetitive task over and over again like recompiling minification testing etc. In this case a Task Runner such as Task Runner is really necessary. In others works its automation tool. It automate the repetitive task such as like minification, compilation, unit testing, linting, etc, the easier your job becomes. After you’ve configured it, a task runner can do most of that mundane work for you-and your team-with basically zero effort.

To install grunt module by the following command:

                npm install grunt

13.Mocha Module

Mocha module is a feature-rich JavaScript test framework running on node.js which helps to asynchronous testing simple and fun. Mocha tests run serially, allowing for flexible and accurate reporting, while mapping uncaught exceptions to the correct test cases.

To install moncha module by the following command:
                npm install moncha

14.  Redis Module

It is a module to communicate with the famous caching server Redis in node.js. This module is a complete Redis client for node.js. It supports all Redis commands, including many recently added commands like EVAL.

To install redis module by the following command:
npm install redis

15.Forever Module

The Forever is the very good module because it gives the facility to node.js run forever. Every node.js developer knows that node.js run from the command prompt every time. It is the fantastic module to run forever. It is closed by simply close the node.js terminal or shutdown your terminal.

To install forever module by the following command:

npm install forever

I hope this blog is helpful for you. Thanks!


Updated 18-Sep-2014

Leave Comment

Comments

Liked By