From 74c02314d1c993402e0284ac4c5c2bd330d2bd75 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Tue, 9 Nov 2021 15:28:28 -0600 Subject: [PATCH] Add Find The Version Of An Installed Dependency as a JavaScript til --- README.md | 3 +- ...-the-version-of-an-installed-dependency.md | 36 +++++++++++++++++++ 2 files changed, 38 insertions(+), 1 deletion(-) create mode 100644 javascript/find-the-version-of-an-installed-dependency.md diff --git a/README.md b/README.md index 9643a38..7088e71 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/javascript/find-the-version-of-an-installed-dependency.md b/javascript/find-the-version-of-an-installed-dependency.md new file mode 100644 index 0000000..894226c --- /dev/null +++ b/javascript/find-the-version-of-an-installed-dependency.md @@ -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.