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.
q
A promise library to let us create promises without the native promise implementation.
This is useful when we didn’t have promises natively built into JavaScript.
ramda
A utility library with functional programming methods.
It includes many methods like array manipulation methods, string manipulation methods, math methods, and much more.
They’re all written and used in a functional way.
ora
The ora library lets add a spinner to the command line Node programs to indicate loading.
file-loader
The Webpack file-loader plugin lets us load static files into our front end apps.
We’ll need it to load images and other static resources within our JavaScript code.
eslint-plugin-import
A ESLint plugin that checks for how we write import and exporter statements in modules.
It’s very handy for checking the syntax automatically so that we don’t make mistakes and commit back practices when writing and using JavaScript modules.
styled-components
A React library that lets us create HTML elements and components that are styled and can be used with React.
It supports static and dynamic styles.
And we create a component by writing out the styles and there transforming them to React components with the functions that are built into the library.
eslint-plugin-react
An ESLint plugin for checking React syntax.
It’s great for helping us from committing syntax errors and bad practices in React apps.
Checks include prop types, names, destructuring assignments, and a lot more.
request-promise
Request-Promise is an HTTP client that lets us make HTTP requests with promises.
It can use native promises or any-promise as the promise to use with the request-promise-native and request-promise-any respectively.
handlebars
Handlebars is a template engine that we can use on templates for various frameworks like Express or Koa.
It includes template tags that we can use to render arrays and conditionally render items as we wish to.
jsonwebtoken
The jsonwebtoken package lets us create JSON web tokens that are secure.
We can sign tokens with them with various expiry dates.
It can encode any object to tokens.
Also, then token issued can expire at any time that we wish.
It also has the functionality to verify tokens.
mongoose
Mongoose is an ODM library for letting us read and write MongoDB documents easier than with the MongoDB library.
We can specify models with data types and constraints so that we can specify models together so that we can always save the right kind of data.
Not only can we specify the type, but we can also specify the format of the data with regex.
url-loader
We can use the url-loader Webpack plugin to load base64 URLs as images with our JavaScript apps.
gulp
Gulp is a package that lets us build JavaScript files automatically without hassle.
We can write many kinds of automated build tasks without running all the commands ourselves.
The tasks can be run in series or in parallel as we wish to.
Also, there’re many plugins written for it so that we don’t have to write tasks ourselves all the time.
Plugins or concatenation, uglifying code is available.
mongodb
MongoDB is the official MongoDB driver for Node.js
It can be used to do common CRUD operations.
@babel/polyfill
If we’re targeting browsers that don’t have full ES6 support, then we can use babel-polyfill to add the polyfills needs to run ES6 code in unsupported browsers.
It includes new array methods, string methods, support for syntaxes like spread and rest, maps, sets, and much more.
object-assign
object-assign is a polyfill for the Object.assign
method.
It’s very handy for copying and merging objects.
ws
A WebSocket client and server made for Node apps.
It supports many options like compression, concurrency, sending various kinds of data, and more.
It also works with Node’s HTTP server.
The client is also made for Node apps and can be used to connect to any WebSocket server.
Conclusion
Polyfills, WebSocket libraries, and spinners are all great packages that we can use in our Node apps.
Also, MongoDB is a popular choice for some use cases as we can see from their popularity in NPM.