LinuxCommandLibrary

npm-search

Search for packages on the npm registry

TLDR

Search for a package by name

$ npm [[s|search]] [package]
copy

Search for packages by a specific keyword
$ npm [[s|search]] [keyword]
copy

Search for packages, including detailed information (e.g., description, author, version)
$ npm [[s|search]] [package] --long
copy

Search for packages maintained by a specific author
$ npm [[s|search]] --author [author]
copy

Search for packages with a specific organization
$ npm [[s|search]] --scope [organization]
copy

Search for packages with a specific combination of terms
$ npm [[s|search]] [term1 term2 ...]
copy

SYNOPSIS

npm search [search terms...] [options]

PARAMETERS

--long
    Display extended information about each matching package

--json
    Output results in JSON format

--parseable
    Tab-separated values for scripting

--no-description
    Omit package descriptions from output

--registry <url>
    Specify a custom registry URL

--limit <number>
    Maximum number of results to return

--target <target>
    Search against specific dist-tag or version target

--date
    Sort by last modified date instead of publish date

DESCRIPTION

The npm search command queries the npm package registry to find modules matching specified search terms. It displays a list of matching packages with key details like name, description, author, date, and keywords.

By default, it performs a keyword-based search and shows concise information for up to 15 results per page. This tool is essential for discovering reusable Node.js modules before installation. Use it to explore available packages, check versions, and review maintainers.

For more detailed output, options like --long provide extended metadata including versions, licenses, and links. JSON or parseable formats support scripting and automation. Note that search relies on the npm registry's search index, which may not cover all packages comprehensively due to recent API limitations.

Ideal for developers scouting dependencies, it integrates seamlessly with other npm workflows like npm install and npm view.

CAVEATS

npm search results are limited (max 250 total) due to registry API deprecations; use npmjs.com for comprehensive searches.
Deprecated in favor of web-based discovery tools.

EXAMPLES

npm search express
Basic search for 'express'.

npm search --long lodash
Detailed results for 'lodash'.

EXIT CODES

0: success
1: failure (network/error)

HISTORY

Introduced in npm v1.0 (2010) for registry keyword search. Enhanced with options in v2+. Registry search API v1 sunset in 2021, now uses limited v2 index.

SEE ALSO

npm(1), npm-view(1), npm-list(1), npm-install(1)

Copied to clipboard