Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 706
labyrinth Avatar asked Jan 27 '17 04:01

labyrinth


People also ask

Where does yarn get packages from?

Most packages will be installed from the npm registry and referred to by simply their package name. For example, yarn add react will install the react package from the npm registry.

How do you connect yarn packages?

yarn link [package...]Use yarn link [package] to link another package that you'd like to test into your current project. To follow the above example, in the react-relay project, you'd run yarn link react to use your local version of react that you previously linked.

Does yarn look at package json?

Every yarn package must have a package. json file which yarn looks for in order to identify the package. This file configures the behavior of yarn while it is running inside that package.


2 Answers

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 
like image 190
Kasiriveni Avatar answered Sep 19 '22 22:09

Kasiriveni


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.

like image 39
Brian Brownton Avatar answered Sep 21 '22 22:09

Brian Brownton