NPM packages are used by both browser and Node.js apps alike. NPM is the biggest repository of JavaScript libraries.
In this article, we’ll look at the popular JavaScript packages on NPM.
bluebird
Bluebird is a popular promise library for making promises. It’s popular before promises are built into ES6 or later.
Now that JavaScript has promises as a native feature, we probably don’t need this as much.
vue
Vue is a popular framework for building front end apps.
It’s full-featured so it includes many things like templating, filters for formatting template content, directives for manipulating the DOM, and the use of components all in one package.
Vue is getting more popular every day, and making simple apps with it is easy
There are many libraries made for it to make our lives easier.
Therefore. we can use it to make apps. With Vuex and Vue Router, we have state management and routing solution to make a standalone front end app with it.
uuid
Thi library lets us create various kinds of unique IDs that we can use for things like unique identifier for database entries and more.
classnames
We can use the classnames library to join class names together conditionally so that we can apply styles dynamically to a web page.
It’s framework agnostic so it can be used in almost any project. However, since there’s a class name manipulation feature in frameworks like Vue and Angular, we shouldn’t use this with those frameworks.
But this library does work great with React, since there’s no easy way to manipulate class names dynamically out of the box.
underscore
Underscore is another popular JavaScript helper library with various methods or manipulating arrays and objects.
Its feature set is smaller than Lodash, some of its methods have plain JavaScript equivalents, so it’s not as useful as it is before.
core-js
Core-js has a set of polyfill that we can add to support browsers that don’t have the libraries built into the browser.
They include the latest arrays and string methods, and also new constructors like Map
and Set
.
Also, the Promise
constructor is included so that we can use native promises instead of 3rd party solutions.
Whatever has been introduced with ES6 or later, this library has them all.
inquirer
Inquirer is a library that lets us build command-line user interfaces with ease.
It has methods for letting us prompt answers and take user input.
We can format questions and answers in the way we like to and we can even use it to create react user interfaces hat listen for answers.
yargs
Is a library that helps us build command-line interfaces by helping us process command line arguments without hassle.
It parses options that are passed in with the command that starts our program so we can use them without parsing them ourselves.
webpack
Webpack is a popular package for letting us bundle modules into packages that can be used in browsers.
It supports many options and are used by the CLIs of popular frameworks like Angular, React, and Vue.
mkdirp
mkdirp
lets us create directories recursively in our Node programs.
The fs module doesn’t have a function that lets us create directories recursively, so we’ve to use this library to do that.
It has both a synchronous and asynchronous version built-in.
rxjs
Rxjs is a popular for library for reactive programming.
It lets us create objects for emitting data, which can be subscribed to other objects.
Also, we can use it to adjust the ways that data is emitted with built-in methods.
glob
Glob lets us search for files from within a Node.js program. We can pass in any path pattern as a string and we get back the results of the paths that match the pattern that we pass in.
By default, the search is done asynchronously, but we can also do it synchronously.
body-parser
This is a package that lets us parse request bodies in our Express apps. It’s available as an Express middleware, so it can be used to parse JSON request bodies.
Since there’s no built-in way to parse JSON request bodies in Express, we have to use this.
Conclusion
Some of these libraries let us build command-line interfaces easily.
We also have Underscore to let us do array and object operations that don’t have plain JavaScript equivalents and are not easy to do.