npm-search
Search for packages on the npm registry
TLDR
Search for a package by name
Search for packages by a specific keyword
Search for packages, including detailed information (e.g., description, author, version)
Search for packages maintained by a specific author
Search for packages with a specific organization
Search for packages with a specific combination of terms
SYNOPSIS
npm search <search terms> [<options>]
npm search [<@scope>/]<search terms> [<options>]
PARAMETERS
--json
Output search results in JSON format for programmatic consumption.
--long
Display extended information for each search result.
--parseable
Output search results in a machine-readable, tab-separated format.
--color
Control colorized output (e.g., always, false).
--search.prefer-online
Prioritize online registry over local cache for search.
--search.description
Include package descriptions in the search criteria.
--search.keywords
Include package keywords in the search criteria.
--search.author
Include package author names in the search criteria.
--search.maintainer
Include package maintainer names in the search criteria.
--search.homepage
Include package homepage URLs in the search criteria.
--search.repository
Include package repository URLs in the search criteria.
--registry
Specify a custom registry URL to search against.
DESCRIPTION
npm search is a powerful command-line utility that allows developers to search the vast npm registry for JavaScript packages and modules. It facilitates the discovery of new libraries, tools, and frameworks by matching user-provided keywords against package names, descriptions, keywords, and other metadata fields. When executed, npm search queries the online registry, returning a list of matching packages along with their current version, a brief description, and sometimes author information. This command is invaluable for exploring the Node.js ecosystem, finding solutions to specific programming challenges, or identifying alternatives to existing dependencies. It operates by indexing package metadata, providing a fuzzy search capability that helps users find relevant results even with approximate terms. The results are typically displayed in a human-readable table, but can also be formatted as JSON or in a parseable format for scripting purposes. An active internet connection is required to use this command as it interacts directly with the npm registry.
CAVEATS
npm search relies on an active internet connection to query the npm registry. The search index used by npm may not be immediately updated with the very latest package publications or metadata changes, leading to a slight delay in results. The quality and relevance of search outcomes are highly dependent on the accuracy and completeness of the metadata provided by package publishers. Search operations can sometimes be slower depending on network conditions and registry load.
SEARCH INDEXING
npm search operates by querying a pre-indexed database of package metadata on the npm registry. This index is periodically updated, meaning that very recently published packages might not appear in search results immediately. The search algorithm performs a fuzzy match across various metadata fields to provide comprehensive results.
SEARCH SCOPE
By default, npm search looks across all publicly available packages on the configured npm registry. It can also find packages within a specific scope (e.g., @myscope/mypackage) by including the scope in the search terms. The search capabilities are limited to the metadata stored in the registry and do not involve local file system scanning.
HISTORY
The npm search command has been a fundamental part of the npm CLI since its early days, serving as the primary tool for package discovery within the Node.js ecosystem. Its core functionality has remained consistent, allowing users to efficiently find packages by keywords. Over time, improvements have focused on enhancing the search index's speed and relevance, as well as providing more granular control over search criteria through options like --search.<field>. It reflects npm's commitment to making the vast collection of open-source JavaScript modules easily accessible to developers.