What NPM packages should be know for starting Node.js development

Nowadays Node.js is being more popular to develop the backend for websites and API. If you are developing your first project on Node.js then you must have the question in your mind that How will I listen to request in the node, How will I manage routes in the node, How will I manage files or how to manipulate files etc. Here we are providing some useful npm modules that will make your node.js development easy. Let start one by one introduction of npm modules that will help you to develop a great product in Node.js.

1.Express

Express is a Node.js framework that provides a robust set of features to develop web and mobile applications. To start a project in Node.js, the best way to use a framework. This provides the following features.

  • Allows to set up middlewares to respond to HTTP Requests.

  • Defines a routing table which is used to perform different actions based on HTTP Method and URL.

  • Allows to dynamically render HTML Pages based on passing arguments to templates

To add express in your node project run following command:

npm install express --save

With express some time you need to add other modules with express to enhance the features of express:

  • body-parser - Parse incoming request bodies in a middleware before your handlers, available under the property req.body.
  • cookie-parser- Parse header and Cookie and populate with an object keyed req.cookies by the cookie names. 
  • multer - Multer is a node.js middleware for handling multipart/form-data, which is primarily used for uploading files.

 

2. Koa -

Expressive HTTP middleware framework for node.js to make web applications and APIs more enjoyable to write. Koa's middleware stack flows in a stack-like manner, allowing you to perform actions downstream then filter and manipulate the response upstream. This is a high performance frameword and best suited for API development.

npm install koa --save

With koa, you need some additional module to install as your requirement.

  •  koa-body - A full-featured koa body parser middleware. Support multipart, URL-encoded and JSON request bodies. Provides same functionality as Express's bodyParser - multer.
  • koa-router -Router middleware for koa. Express-style routing using app.get, app.put, app.post, etc. Named URL parameters. Named routes with URL generation. Responds to OPTIONS requests with allowed methods etc.
  • koa-send - Static file serving middleware.
  • koa-static - Koa static file serving middleware, a wrapper for koa-send
  • koa-logger - Development style logger middleware for koa.
  • koa-helmet - koa-helmet is a wrapper for helmet to work with koa. It provides important security headers to make your app more secure by default.
  • koa-combine-routers - Convenience middleware for composing multiple instances of koa-router.
  • koa-json-filter -Middleware allowing the client to filter the response to only what they need, reducing the amount of traffic over the wire using the ?filter=foo,bar,baz query string parameter.

 

3. Moment - 

A lightweight JavaScript date library for parsing, validating, manipulating, and formatting dates.

npm install moment --save

 

4. Sequelize - 

Sequelize is a promise-based Node.js ORM for Postgres, MySQL, SQLite and Microsoft SQL Server. It features solid transaction support, relations, read replication and more.

npm install --save sequelize
 
# And one of the following: 
npm install --save pg pg-hstore
npm install --save mysql2
npm install --save sqlite3
npm install --save tedious # MSSQL

 

5. Mongoose - 

Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment.

npm install mongoose --save

 

6. Dgraph-orm - 

Dgraph ORM is a package to simplify the schema creation for Dgraph database similar to Mongoose, Sequilize and etc.

npm install dgraph-orm --save

 

7. Jsonwebtoken - 

Authentication token creates and verify module for Node.js. Best suited for API development to generate JWT tokens.

npm install jsonwebtoken --save

 

8. Node-thumbnail - 

Node-thumbnail creates a queue of images and converts them asynchronously into thumbnails. node-thumbnail has no binary dependencies.

npm install node-thumbnail --save

 

9. Nodemailer - 

Send e-mails from Node.js easily using this module. SMTP credentials are required to send mail using this library like Google, mailgun, sendgrid etc.

npm install node-thumbnail --save

 

10. Dotenv -

Dotenv is a zero-dependency module that loads environment variables from a .env file into process.env. Storing configuration in the environment separate from code is based on The Twelve-Factor App methodology.

npm install dotenv --save

 

11. Cron - 

Cron is a tool that allows you to execute something on a schedule. This is typically done using the cron syntax. 

npm install cron --save

 

12. Edge.js - 

Edge is a logical templating engine for Node.js. The syntax language is naturally similar to Javascript, making it simpler to write and remember.

npm install edge.js --save

 

13. Dayjs - 

Day.js is a minimalist JavaScript library for modern browsers with a largely Moment.js-compatible API. If you use Moment.js, you already know how to use Day.js.

npm install dayjs --save

 

14. Bcrypt - 

Library to help you hash passwords and match password that is hash.

npm install bcrypt --save

 

15. Html-pdf - 

Create PDF file from HTML in Node.js.

npm install html-pdf --save

 

16. Node-xlsx - 

Read Excel file in Node.js and convert into JSON format for further use.

npm install node-xlsx --save

 

17. Node-imageinfo -

This is a small package for node.js to allow the analysis of image data in a Buffer, and return mime-type, and image dimensions for the data.

npm install imageinfo --save

 

18. Sharp - 

The typical use case for this high-speed Node.js module is to convert large images in common formats to smaller, web-friendly JPEG, PNG and WebP images of varying dimensions.

npm install sharp --save

 

19. Aws-sdk - 

 The official AWS SDK for JavaScript, available for browsers and mobile devices, or Node.js backends.

npm install aws-sdk --save

 

20. logger - 

A simple logging library that combines the simple APIs of Ruby's logger.rb and browser-js console.log(). Write your logs into a file.

npm install logger --save


Keywords: