Node.js package management system: Finding npm packages

By default, npm packages are retrieved over the internet from the public package registry maintained on If you know the module name, it can be installed simply by typing the following:

$ npm install moduleName

 But what if you don’t know the module name? How do you discover the interesting modules? The website publishes a searchable index of the modules in the registry. The npm package also has a command-line search function to consult the same index:

Of course, upon finding a module, it’s installed as follows:

$ npm install acoustid

The npm repository uses a few package.json fields to aid in finding packages.

The package.json fields that help finding packages

For a package to be easily found in the npm repository requires a good package name, package description, and keywords. The npm search function scans those package attributes and presents them in search results.

The relevant package.json fields are as follows:

{ …

“description”: “My wonderful package that walks dogs”,

“homepage”: “”,

“author”: “”,

“keywords”: [ “dogs”, “dog walking” ]

… }

The npm view command shows us information from package.json file for a given package, and with the —json flag we’re shown the raw JSON.

The name tag is of course the package name, and it is used in URLs and command names, so choose one that’s safe for both. If you desire to publish a package in the public npm repository, it’s helpful to check whether a particular name is already being used by searching on or by using the npm search command.

The description tag is a short description that’s meant as a brief/terse description of the package.

It is the name and description tags that are shown in npm search results.

The keywords tag is where we list attributes of the package. The npm website contains pages listing all packages using a particular keyword. These keyword indexes are useful when searching for a package since it lists the related packages in one place, and therefore when publishing a package it’s useful to land on the correct keyword pages.

Another source is the contents of the file. This file should be added to the package to provide basic package documentation. This file is shown on the package page on, and therefore it is important for this file to convince potential users of your package to actually use it. As the file name implies, this is a Markdown file.

Once you have found a package to use, you must install it in order to use the package.

Source: Herron David (2020), Node.js Web Development: Server-side web development made easy with Node 14 using practical examples, Packt Publishing.

Leave a Reply

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