How do I search for packages using yarn?

How do I search for packages with yarn? I want to get a list of results that have the search term in the name of the package as well as in descriptions (similar to how various utilities work like npm search, apropos, apt-cache search).

I tried yarn info <pkg>, but this gave a bunch of json data that was limited to just that package.

Using yarn help and duckduckgo was educational, but still didn't answer how to do this.


Solution 1:

there is no command for showing the tabular data format of package information

if you what more information about the packages you can try below commands you will get more information

yarn info package

yarn info package  --json

yarn info package@version

yarn info package description

yarn info package time

yarn info package readme

Solution 2:

I came here via google and none of the answers really explained anything about WHY search was "missing", so I dug in a bit.

From the Yarn dev's github issue tracker, this exact topic was brought up:

kittens commented on Oct 12, 2016

We've deliberately decided not to add these sorts of commands to Yarn. There's a lot of them that don't actually see much use and the maintenance burden isn't really worth it. If the functionality of the commands is so simple (just opening a browser) then you can just do it yourself. Thanks for the report!

So there you go, it has been intentionally not included and there are currently no plans to include it.

As others have said, you can either use npm's search as both yarn and npm fetch from the same list of packages, or you can use a web-based solution:

  • https://www.npmjs.com/
  • https://www.npms.io/
  • etc

Hope this helps others save a few minutes in their quest for an answer.

Solution 3:

Yarn has a website which has information and a detail page for every package in the registry. It’s available on yarnpkg.com/en/packages and provided by Algolia.

Since the npm and Yarn registry are the same, you can also use every tool that shows this data, like npms.io or similar.


Fair disclosure: I work for Algolia and am in charge of the search page of Yarn.

Solution 4:

I use npms-cli:

Install:

yarn global add npms-cli

Then you will have available /usr/bin/npms and can search like: npms search <desired package>.