1. Express
Express is the first choice for developers who build APIs using NodeJS. It has best in class routing features, higher performance, helper methods, support for templating engines and many more. The best part of using express is that it is easy and fast to work with.
Setup Steps
- In your node project, install express by executing the command in shell/cmd
npm i express
- In the app.js or index.js, write the following code to configure the root GET route.
const express = require(‘express’);
const app = express();
app.get(‘/’, function(req, res) {
res.send(‘Hello World’);
});
app.listen(3000);
2. Mongoose
Mongoose is an object modelling wrapper over the MongoDB. It helps to define schema and model classes for NoSQL collections. Mongoose supports asynchrony with the help of callbacks and promises.
Setup Steps
1. In your node project, install mongoose by executing the command in shell/cmd
npm i mongoose
2. In the app.js or index.js, write the following code to configure the root GET route.
const mongoose = require(‘mongoose’);
mongoose.connect(‘mongodb://localhost/genreDatabase’, {
useNewUrlParser: true,
useUnifiedTopology: true
})
.then(() => console.log(‘Connected to database…’))
.catch(err => console.log(‘Error’, err));
const genreSchema = new mongoose.Schema({
name: {
type: String,
required: true
}
});
const Genre = mongoose.model(‘Genre’, genreSchema);
//Now, you can use Genre class to create/manipulate/delete objects
app.listen(3000);
3. Nodemon
Nodemon is a simple package that helps you to restart the NodeJS application when file changes are detected. This comes in handy as developers need not use “npm start” or “node index.js” every time they have to restart the application.
Setup Steps
1. In your node project, install nodemon by executing the command in shell/cmd
npm i nodemon
2. When you want to run the application, just type the following command and the application will detect changes and auto-restart
nodemon index.js
4. Helmet
Helmet is an effective package that helps you secure your application by setting various HTTP headers. This package ensures that there is a certain set of protection in your application by default. It is better than having no security. There are more options that you can set in your helmet middleware configuration. Refer helmet docs for more information.
Setup Steps
1. In your node project, install helmet by executing the command in shell/cmd
npm i helmet
2. In the app.js or index.js, write the following code to configure the helmet middleware.
const express = require(‘express’);
const helmet = require(‘helmet’);
const app = express();
// attach helmet as a middleware
app.use(helmet());
5. CORS
CORS package helps provide the ability to configure the Allow-Control-Allow-Origin header inside the application code. This is much better than setting your headers with plain text in your application code. CORS is mostly used in conjunction with Express for ensuring that your API endpoints are allowed to use form known origins.
Setup Steps
1. In your node project, install cors by executing the command in shell/cmd
npm i cors
2. In the app.js or index.js, write the following code to configure the CORS middleware.
const express = require(‘express’);
const cors = require(‘cors’);
const app = express();
// attach CORS as a middleware
app.use(cors({ origin: ‘http://localhost:4200‘ }));
app.get(‘/’, function(req, res) {
res.send(‘This API endpoint on 3000 port can only be reached from localhost:4200’);
});
app.listen(3000);
6. Config
Config package comes handy in specifying default and environment specific configurations stored as JSON files. It can detect the process.env.NODE_ENV and pick the right configurations automatically.
Setup Steps
1. In your node project, install config by executing the command in shell/cmd
npm i config
2. Create a json file named “development.json” [indicates the json file is for development environment]
{
“appName”: “My App”,
“mail”: {
“host”: “server host url”
}
}
3. In the app.js or index.js, write the following code to read the configuration values.
const config = require(‘config’);
const appName = config.get(‘appName’);
const hostUrl = config.get(‘mail.host’);
7. Debug
Debug package helps us specify debug statements rather than polluting with console.log. You can choose to execute debug statements for a particular environment (like development) and not execute it on production environments. You can also get creative with process variables and have the application log debug statements in a particular time period to understand the issue going on.
Setup Steps
1. In your node project, install debug by executing the command in shell/cmd
npm i debug
2. In the app.js or index.js, write the following code for debugging statements.
const debug = require(‘debug’);
if (process.env.NODE_ENV === ‘development’)
debug(‘This is a debug statement’);
8. Morgan
Morgan is an HTTP request logger middleware for NodeJS. It is useful when you have many middleware and you want to know the sequence of the request flow through various middleware in your application. Morgan can log the request pipeline flow in various formats.
Setup Steps
1. In your node project, install morgan by executing the command in shell/cmd
npm i morgan
2. In the app.js or index.js, write the following code to log the HTTP request pipeline.
var express = require(‘express’);
var morgan = require(‘morgan’);
var app = express();
app.use(morgan(‘combined’));
app.get(‘/’, function(req, res) {
res.send(‘hello, world!’);
});
9. React
React is a popular javscript library for creating user interfaces. It provides ability to create components and render the components by interacting with DOM elements (for web) or native elements (for native environment).
Setup Steps
1. In your node project, install react by executing the command in shell/cmd
npm i react
As you all know. configuring React for developing your frontend can be a story on its own! We will write on React package in a separate blog post.
In a nutshell, we have picked the NPM packages based on the popularity, user adoption, our own hands-on experience and ease of use. These packages help us save a lot of time in setting up the base for our Node development. This is a huge benefit when it comes to developer productivity. So, go ahead and try using these packages for your Node project. If you have any more recommendations, please feel free to comment on this post.

Author Bio
Abhishek Sivasubramanian works with Suyati as a Associate Director – Technology. He is an International Speaker at world’s largest conferences like Dreamforce, IEEE and ICWS and has been a mentor for many newbies & professionals in the IT Industry.
Abhishek Sivasubramanian works with Suyati as a Development Lead in Salesforce CRM & .NET Application Development. He is an International Speaker at world’s largest conferences like Dreamforce, IEEE and ICWS and has been a mentor for many newbies & professionals in IT Industry.