1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-02 22:58:01 +00:00

Add Find The Version Of An Installed Dependency as a JavaScript til

This commit is contained in:
jbranchaud
2021-11-09 15:28:28 -06:00
parent 48299a7c0c
commit 74c02314d1
2 changed files with 38 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
_1163 TILs and counting..._
_1164 TILs and counting..._
---
@@ -382,6 +382,7 @@ _1163 TILs and counting..._
- [Easy Date Comparison With DayJS](javascript/easy-date-comparison-with-dayjs.md)
- [Expand Emojis With The Spread Operator](javascript/expand-emojis-with-the-spread-operator.md)
- [Fill An Input With A Ton Of Text](javascript/fill-an-input-with-a-ton-of-text.md)
- [Find The Version Of An Installed Dependency](javascript/find-the-version-of-an-installed-dependency.md)
- [Find Where Yarn Is Installing Binaries](javascript/find-where-yarn-is-installing-binaries.md)
- [for...in Iterates Over Object Properties](javascript/for-in-iterates-over-object-properties.md)
- [Formatting Values With Units For Display](javascript/formatting-values-with-units-for-display.md)

View File

@@ -0,0 +1,36 @@
# Find The Version Of An Installed Dependency
I recently ran into a bug related to a specific version of a dependency. As
part of tracking it down, I needed to figure out what version I had installed.
The [`yarn list`](https://classic.yarnpkg.com/en/docs/cli/list) command can
help with this. Without any flags, it will show a tree structure listing _every
single_ dependency and sub-dependency that is installed for your project.
Here is an example of what that looks like restricted to a pattern of `jest`.
```bash
$ yarn list --pattern jest
yarn list v1.22.10
├─ @testing-library/jest-dom@5.14.1
├─ @types/jest@27.0.1
├─ @types/testing-library__jest-dom@5.9.5
│ ├─ @jest/types@26.6.2
│ ├─ @types/jest@26.0.23
│ ├─ jest-diff@26.6.2
│ └─ jest-get-type@26.3.0
...
```
I can look through this list and find the dependency and version of interest.
It's still a lot of results to comb through, so what I like to do instead is
pipe it to [`fzf`](https://github.com/junegunn/fzf).
```bash
$ yarn list | fzf
```
Then I can interactively narrow down the results with the power of FZF's fuzzy
finding functionality.