Categories
JavaScript

Handy NPM Packages You May Have Missed

Spread the love

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.

colors

We can use this library to display text with colors with little effort.

We can use it to set colors in various colors. The background color can also be changed.

With this, we can choose between bright and normal background colors.

It can also make text bold, italic, and apply other text styles.

dotenv

Dotenv is a useful library for letting us read environment variables from .env files.

It’s also useful for reading environment variables directly from the operating system.

Therefore, it’s great for back end apps.

We can control how .env files are read, including whether we want to include whitespace or # into our app.

jquery

The once-popular jQuery library for DOM manipulation is also available as a Node package.

It provides lots of DOM manipulation functionality like manipulating class names, changing styles on the fly, and many more things.

Also, it has many utility functions like the ajax function for making HTTP requests and much more.

typescript

The TypeScript package lets us add TypeScript support into our project.

Using TypeScript has many benefits. It adds many capabilities into JavaScript, like data type annotations, data type checking, while retaining the flexibility of the JavaScript type system.

Therefore, we can make many data types with it like union types, intersection types, nullable types, literal types, generic types, and much more.

minimist

The minimist library lets us parse command-line arguments into a format that we can use easily.

We can call the function that comes with the package and then it returns a JavaScript object that we can use in our program.

aws-sdk

This is the official AWS SDK for Node apps. It lets us use their services within our Node app.

AWS has many services including file storage, cloud hosting, image recognition, and much more.

@types/node

This package lets us add TypeScript type annotation for built-in Node modules.

We can use this to help us with development by providing autocomplete for standard Node modules.

semver

semver is a semantic version parse for Node apps.

We can parse semantic version names into strings with it.

Also, we can use them to compare versions and get the minimum versions given a version string.

redux

Redux is a state management library. It’s often paired with React-Redux to create a state management solution for React apps.

We need centralized state management because there’s no easier way to share data between components of a complex front end app.

eslint

ESLint is a linter for JavaScript. It checks for syntax errors and bad coding practices for JavaScript projects.

By default, it has many rules built-in and we can add plugins to expand the sets of rules that it provides.

It supports the latest JavaScript syntax and is aware of deprecated and bad syntax so it’s very handy too to have when developing any JavaScript project.

winston

Winston is a logger that lets us log data in Node.js apps.

It can be used for simple logging and it also has many formatting features to format our log file the way we want.

We can filter data and change the logging level to be the level that we want.

node-fetch

This library brings the Fetch API to Node.js. The Fetch API is an HTTP client that’s standard in browsers.

It’s a replacement of the XMLHttpRequest constructor that we were using before.

Fetch API is promise-based, and supports making many more kinds of requests and can process responses automatically unlike the old XMLHttpRequest constructor.

With this package, we can use it in Node apps.

css-loader

css-loader is a module for adding CSS importing capabilities into Webpack.

With it, we can import CSS files in our JavaScript code files as a string and use them the way we like.

Conclusion

ESLint is one of the most popular linter for checking for syntax and code styling issues with Node.js.

Winston is a popular logger for Node.js apps.

We also have libraries for showing colors in the command line, command-line argument parser, and more.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *