Npm-search and npm-shrinkwrap cli commands

There are certain times where you don't the exact name of the package you want; in such cases you can use the npm-search command to search for the package, this will help you eliminate the error of installing wrong package.

There are also times when you want to lock down dependency versions for publication, for this npm provides the npm shrinkwrap cli option.

This tutorial will work you though both cli options.


The npm-search is used to search for packages.


npm search [-l|--long] [--json] [--parseable] [--no-description] [search terms ...]

aliases: s, se, find


The npm-search will search for the packages that matches your search terms. The search performed by npm search is a linear, incremental, lexically-ordered search through package metadata for files in the npm registry. If you have color enabled. It will highlight the matches in the results.

In addition, when you use the -searchopts and -searchexclude, options that paired with more search terms will include and exclude further patterns respectively. The main difference between the standard search terms and -searchopts is that -searchopts does not highlight results in the output and can be used when we need more fine-grained filtering. Additionally, you can add both the -searchopts and -searchexclude to the .npmrc for default search filtering behavior.

Search equally enables you to target maintainers in search results, this is done by prefixing their npm username with =.

Whenever a term starts with /, it is interpreted as a regular expression and will support standard JavaScript RegExp syntax. A trailing / is ignored in this case. (it should be noted that many regular expression characters have to be escaped or quoted in most shells)



When used as -no-description, it disables search matching in package descriptions and suppresses the displays of that field in the results.

  • Default: true
  • Type: Boolean


The json config option outputs search results as a JSON array.

  • Default:false
  • Type: Boolean


This displays a full package description and other long text across multiple lines. When it is disabled (which is the default) search results will be truncated to fit neatly on a single line. Modules that have extremely long names will fall on multiple lines.

  • Default: false
  • Type: Boolean


  • Default: ""
  • Type: String

These are space-separated options that are always passed to search.


  • Default: ""
  • Type: String

These are space-separated options that limit the results from search.


  • Default: 900 (15 minutes)
  • Type: Number

This is the age of the cache, in seconds, before another registry request is made.


  • Default: https://registry.npmjs.org/
  • Type: url

Searches the specified registry for modules. If you configured npm to point to a different default registry, like your internal private module repository, npm search defaults to that registry when searching. You should pass a different registry url such as the default above in order to override this setting.


The npm shrinkwrap helps you to lock down dependency versions for publication.


npm shrinkwrap


This command will repurpose package-lock.json into a publishable npm-shrinkwrap.json or it will simply create a new one. The file that is created and updated by this command then takes precedence over any other existing or future package-lock.json files.

Previous: Npm rebuild, repo, restart, root and run-script commands
Next: Npm-star, stars, start and stop cli commands

Follow us on Facebook and Twitter for latest update.