JavaScript is a synchronous single-threaded language. It is the most widely used programming language for software and application development. Many frameworks like Reactjs, Angularjs, Vuejs, Expressjs, and Node.js have been developed with their base language, JavaScript. Many developers face issues while coding in JavaScript because of various complex concepts like promises, eventloop, callbacks, hoisting, closures, etc. To make development in JavaScript easier, many Node.js packages are available that help in handling errors, formatting code, deleting files, debugging code, ensuring security, etc. Some also provide interactive command line user interfaces for better visual representations of CPU power, processing capacity, the severity of errors, etc.
Retire.js
Retire.js is a Javascript library that provides a list of vulnerabilities associated with other Javascript Library versions. It can be used as a Chrome extension, Firefox extension, command line scanner, Grunt Plugin, etc. It can be installed by using the following command: Retire.js has various commands to scan JavaScript and node files. It scans JavaScript websites and logs the warnings in the developer’s console. Retire.js generates exit code 13 when it finds vulnerabilities. Gulp task automatically scans files and reports the vulnerabilities.
Np
Np is a JavaScript package that provides various features like code cleanup, dependencies installation, package and tags publishing, etc. It ensures that the code is pushed to the master branch and provides an interactive UI. Two-factor Authentication is used to ensure security for new repositories. It ensures that work is done on the latest version by reinstalling dependencies. The latest version is pushed to npm. It can be installed using the following command: Its various features include publishing code from any branch, creating subdirectories for publishing, skipping cleaning up code and testing, etc. Configuration of np can be done globally and locally by CLI flags in the config files of np like np-config.js and no-config.json.
ESLint
ESLint is a JavaScript package tool that parses JavaScript and identifies patterns in ECMA/ JavaScript code. It evaluates patterns in code using AST. All the rules of the tool are defined in the form of plugins, and they can be added dynamically at run time. ESLint can be installed using the below command: After installing it using the above command, a .eslintrc file is generated with a set of rules with error definitions and their respective conditions. ESLint allows all the dependencies to be defined in the .lock file of the user and doesn’t use a .lock file of its own. It is also highly secure.
Shelljs
Shelljs is an environment where UNIX commands can be executed on any operating system over the Node.js API. Shelljs is portable, and it supports third-party plugins too. The various commands that can be used are echo, exec, chmod, pushd, popd, cd, cat, etc. The following command can be used to install Shelljs. It has been tested in various projects like Firefox, JSHint, ESLint, Zepto, etc. Local import of Shelljs packages is preferred over global imports. It can also be configured as silent, fatal, verbose, etc.
Omelette
Omelette provides a template for auto-completion of code for Node and Deno projects. It uses super easy API and supports Async API and Tree API too. A sample code snippet for implementing Omelette is shown below: After importing Omelette, an Omelette object has to be created. Then, various functions for auto-completion of code like, setupShellInitFile() for setup, cleanupShellInitFile() for cleanup can be called on the omelette object for code auto-completion. It also supports the use of Lambda functions for creating complex template literal APIs.
Prettier
Prettier is used for formatting code. It helps in giving tab spaces, keeps track of the maximum content in one line, and ensures proper indentation within conditional and loop statements. It converts code into a neat and readable format. For example: The code snippet is given below, gets converted to the one below when the Prettier extension is used: It can run in CI environments, Integrated Development Environments (IDEs), etc.
jscpd
jscpd is a technical debt management service. It is a JavaScript package that helps find duplicate code snippets across various codes and digital documents. It uses a string matching algorithm called Rabin-Karp for finding code duplications. jscpd/core has the ability to detect code duplication in various environments, and jspd/tokenizer is used for tokenizing the program source code. Apart from these, many other packages like html-reporter, badge-reporter, leveldb-store, etc. The command for installing jscpd is: jscpd is used by GitHub Super Linter, Code-Inspector, Mega-Linter, Codacy, etc. Each of them use jscpd for a different purpose. They use it for natural language processing, line aggregators, code analysis, etc.
Vtop
Vtop is a monitor that gives a graphical representation of command line activity. It gives information about CPU utilization by analyzing the various threads and processes running and representing them graphically through charts, spikes, etc. It was developed using JavaScript, Makefile, and Shell. The command for installing Vtop is: Various themes and color codes can be used to make the GUI more attractive as per the requirements. Various keyboard shortcuts like “u” for an update, “g” to go to the top process of the list, “G” to move to the end of the list, “dd” to kill processes belonging to a particular grp, etc. can be used.
Standardjs
Standardjs is a JavaScript library that automates file configuration, formats code, and quickly finds issues with programmers’ exception handling. The command to install Standardjs is given below: After installing it, you can run it over a file/ code snippet using the “standard” command in the command line interface. All the dependencies of Standardjs can be added by defining “standard: “*” in the dependency object of the package.json file. It can also be installed as a plugin for various text editors like Visual Studio Code, Sublime Text, Atom, Vim, Brackets, etc. Node.js, Expressjs, npm, Brave, and GoDaddy use Standardjs to satisfy their business requirements.
NodeJsScan
NodeJsScan is a Static Security code Scanner for Node.js applications. It informs about an application’s security status via an interactive UI. It can be integrated with various applications like Slack for alerts/notifications, Email alerts by configuring SMTP settings in the settings.py file of NodeJsScan, CI/CD pipeline, etc. It also helps in building docker images. It logs errors, information, and warning messages. A detailed description of the error, like the reason for its occurrence, its severity, the line numbers where the errors occurred, the number of files scanned and issues found, etc. Graphs and charts are also plotted for better readability and analysis.
Trash
Trash is a JavaScript library that moves the deleted files into the trash instead of permanently deleting them. It supports Mac, Linux, and Windows. The command used to install Trash is: Trash is an API that takes input and options as function parameters when the trash() function is invoked. The input could be a string or a string array. Options could be an object. The trash function returns a promise. Different commands are used in different operating systems. macOS-trash is used in MacOs, XDG Spec in Linux, and recycle-bin in Windows.
Xo
Xo is a JavaScript and TypeScript wrapper that uses ESLint underneath. It helps create readable code by giving indentation to code, adding semicolons, single quotes, commas, etc., wherever required. Many ESLint plugins like unicorn, import, ava, n, etc. can be used with Xo. The command used to install xo is: Issues can be fixed automatically using the $xo –fix command. Xo can be configured by using the xo property in the package.json file. It can be installed as a plugin for various editors like Vim, Visual Studio Code, Atom, Sublime Text, Emacs, etc.
diff2html
diff2html stands for “diff parser and pretty HTML generator”. It highlights the changes in the code of the current version as compared to the previous version. It helps developers easily identify and understand what changes have been made. It does this using color codes. It does this by highlighting line-by-line and side-by-side changes. It highlights the code syntax changes and groups similar lines together to easily track code changes. The command to install diff2html is as below: It is also integrated with the command line. Some projects using diff2html are Jenkins, Codacy, Ungit, git-explorer, code-annotation, etc.
Chalk
Chalk is a Node.js module that helps in formatting and styling code. It also helps in creating and adding color themes to text. It is an expressive API, and its performance is excellent. It nests styles and has no dependencies. The usage of Chalk can be seen in the code snippet below: chalk.level defines the colors that are supported at each level. ‘0’ indicates that all colors are disabled, ‘1’ indicates basic color support, ‘2’ indicates 256 color support, and ‘3’ indicates Truecolor support. The various style modifiers to format text supported by chalk are inverse, hidden, visible, strike through, bold, reset, italic, underline, overline, dim, etc.
NpKill
Npkill is a tool that removes old and heavy node-module folders. It helps in removing node modules very quickly and clearing up space in your system. It was developed using TypeScript, JavaScript, and Go. It doesn’t have any dependencies and is easy to use. The command used to install Npkill is: All the node modules specified in the path with the npkill command will be deleted. However, one has to be careful while deleting the node modules because it is irreversible. If the modules of any active project get deleted in the process, the files get corrupted, and the node modules have to be installed again.
fkill-cli
fkill-cli is an open-source and interactive command line tool that kills Linux processes and ports. It was developed using Node.js. It is simple, free, secure, and cross-platform compatible. It works on Windows, Linux, and macOS. The command used to install fkill-cli is: The process name and ID are required to kill the process. “-f” forces the operation to execute while the “-v” command displays process arguments. The fkill API takes inputs and options as its arguments and returns a promise object. Some options are force, silent, ignoreCase, tree, and forceAfterTimeout.
Localtunel
Localtunnel is a platform that enables sharing web services from an external environment with a computer’s local environment without altering the system’s DNS and firewall settings. The requests are proxied by Localtunnel and are passed to the locally deployed server after assigning it with a publicly accessible URL. The command used to install Localtunnel is as follows: It is secure and uses HTTPS requests. These APIs can be used to test webhooks. UI can be tested in cloud browsers using Localtunnel.
Inquirer.js
Inquirer.js is an interactive command line user interface for Node.js applications. It eases the process of finding errors, parsing input, validating answers, and managing hierarchical prompts. It uses native ESM modules for the implementation of its functionalities. The command used to install Inquirer.js is: Various methods used include prompt, registerPrompt, createPromptModule, etc. prompt() is a function that takes question and answer as inputs and returns a promise when invoked. Question is an object which is a hashed version of question-related values like type, message, default, choices, filter, etc. The answer key-value object pair contains the hashed version of client responses. The key is the question property, while the value can contain confirm, input, number, rawlist, etc.
http-server
http-server is a command line static http-server. It is simple and doesn’t require any configurations. It consists of 2 files: namely, index.html and 404.html. index.html is the default file that would be rendered on requests. 404.html is rendered when a file is not found. The command used to install http-server is as shown below: It was developed using HTML and JavaScript. It ensures security through TLS/SSL certificates. It uses the RSA algorithm for key encryption and decryption. It also allows one to define a passphrase along with a private key for security purposes.
Final Words
JavaScript is the most widely used programming language for software development. To make the lives of developers easier, various Node.js packages were developed. Node.js packages like Retire.js, Localtunnel, Xo, Inquirer.js, Shelljs, fpkill, NodeJsScan, Prettier, etc. can be used for formatting code, ensuring security, highlighting code changes, deleting heavy and unwanted node modules, etc. This helps developers debug, write and manage their code efficiently. You may also read about how to install Node.js and NPM on Windows and macOS.