Node.js Modules I Can't Live Without

Posted in #programming

I've been writing and maintaining so many Node.js scripts lately that I've lost count. Node modules allow you to extend scripts to do just about anything you need. There are several Node.js modules that I find myself using over and over again in nearly every project I work on. Here are a few of my favorites that I'm sure will make writing your Node.js scripts easier and more bulletproof. All of these modules are well-documented and supported.

Bluebird

Bluebird is a promise library that outperforms ES6's and other native promise implementations. Bluebird can get very complex, but I find that promisifyAll(), Promise.all(), and your standard thenables handle 95% of my needs.

http://bluebirdjs.com

Ramda

Ramda is a practical functional library for JavaScript programmers. Ever since I started playing around with functional JavaScript programming, Ramda has been invaluable. There are custom implementations of the standard map, filter, and reduce methods that take the data as the last parameter. This lets you easily pipe data through composable functions creating elegant, point-free code. The library is loaded with helper functions that can solve almost all of your data transformation needs.

http://ramdajs.com

Moment & Moment Timezone

Moment.js and Moment Timezone are two great modules that allow you to "parse, validate, manipulate, and display dates and times in JavaScript." The timezone functionality is extremely helpful and intuitive. Any time there is a need to work with dates and times, I turn to this very reliable codebase.

http://momentjs.com

AWS-SDK

Most of my scripts run on Amazon Web Services, so using the AWS-SDK helps manage everything from security to interacting with SNS and other AWS services. If you're using AWS Lambda, then it is already available and you don't need to include it as a dependency.

https://aws.amazon.com/sdk-for-node-js/

MySQL

Interacting with a MySQL or Aurora database is made much simpler using this excellent module by Doug Wilson. Couple this with the Bluebird promise library using Promise.promisifyAll(require("mysql/lib/Connection").prototype); and managing asynchronous data calls is extremely easy.

https://github.com/mysqljs/mysql

Redis

NodeRedis is another great project for managing connections to your Redis server or ElasticCache cluster. Support for batching makes sending multiple requests simple, significantly cutting down roundtrips to the server and speeding up your application.

https://github.com/NodeRedis/node_redis

Validator

Validator is a great validation module that will validate strings as email, UUIDs, FQDNs, etc. There are also a bunch of sanitizers that can be used to normalize text.

https://github.com/chriso/validator.js

What are your favorite Node.js modules?

Update: Someone asked me about async / await instead of promises. I think that is a great approach, but I publish a lot of Node.js on AWS Lambda. As of now it only supports up to v6.10, so I'd have to polyfill.

Comments are currently disabled, but they'll be back soon.