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.
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
- cookie-parser- Parse header and
Cookie andpopulate with an object keyed
req.cookiesby the cookie names.
- multer - Multer is a node.js middleware for handling
multipart/form-data, which is primarily used for uploading files.
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-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,bazquery string parameter.
npm install moment --save
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
Mongoose is a MongoDB object modeling tool designed to work in an asynchronous environment.
npm install mongoose --save
Dgraph ORM is a package to simplify the schema creation for Dgraph database similar to Mongoose, Sequilize and etc.
npm install dgraph-orm --save
Authentication token creates and verify module for Node.js. Best suited for API development to generate JWT tokens.
npm install jsonwebtoken --save
Node-thumbnail creates a queue of images and converts them asynchronously into thumbnails. node-thumbnail has no binary dependencies.
npm install node-thumbnail --save
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
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
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
npm install edge.js --save
npm install dayjs --save
Library to help you hash passwords and match password that is hash.
npm install bcrypt --save
Create PDF file from HTML in Node.js.
npm install html-pdf --save
Read Excel file in Node.js and convert into JSON format for further use.
npm install node-xlsx --save
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
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
npm install aws-sdk --save
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