From 05deaf1f46f2519128cf182bdf9f44b27fa6dcad Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Sun, 20 Dec 2020 00:41:50 -0600 Subject: [PATCH] Add Ensure Shell Can Find Global npm Binaries as a javascript til --- README.md | 3 +- ...sure-shell-can-find-global-npm-binaries.md | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 javascript/ensure-shell-can-find-global-npm-binaries.md diff --git a/README.md b/README.md index 2bced9e..e82429b 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ and pairing with smart people at Hashrocket. For a steady stream of TILs, [sign up for my newsletter](https://tinyletter.com/jbranchaud). -_977 TILs and counting..._ +_978 TILs and counting..._ --- @@ -333,6 +333,7 @@ _977 TILs and counting..._ - [Destructure With Access To Nested Value And Parent Value](javascript/destructure-with-access-to-nested-value-and-parent-value.md); - [Destructuring The Rest Of An Array](javascript/destructuring-the-rest-of-an-array.md) - [Enable ES7 Transforms With react-rails](javascript/enable-es7-transforms-with-react-rails.md) +- [Ensure Shell Can Find Global npm Binaries](javascript/ensure-shell-can-find-global-npm-binaries.md) - [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) diff --git a/javascript/ensure-shell-can-find-global-npm-binaries.md b/javascript/ensure-shell-can-find-global-npm-binaries.md new file mode 100644 index 0000000..f56c5d5 --- /dev/null +++ b/javascript/ensure-shell-can-find-global-npm-binaries.md @@ -0,0 +1,30 @@ +# Ensure Shell Can Find Global npm Binaries + +When you install a package globablly either with yarn (or npm) + +```bash +$ yarn global add vercel +``` + +It places the binaries for that package in the `bin` directory of your package +manager's configured path prefix. + +The absolute path to this `bin` directory can be found with: + +```bash +$ yarn global bin +/Users/jbranchaud/.asdf/installs/nodejs/15.4.0/.npm/bin +``` + +You can ensure that everything located in that `bin` directory is on your +shell's path by adding the following line to your shell's config file (e.g. +`.bashrc` or `.zshrc`). + +```bash +export PATH="$PATH:$(yarn global bin)" +``` + +Once you've updated your shell config, make sure you _source_ the file or +restart your shell. + +[source](https://stackoverflow.com/a/40333409/535590)