From 9a9cebaa11723b0d5bfc4809b6fe824164626f8e Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Wed, 28 Feb 2024 12:40:48 -0600 Subject: [PATCH] Add Open Global npm Config File as a JavaScript TIL --- README.md | 3 ++- javascript/open-global-npm-config-file.md | 30 +++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 javascript/open-global-npm-config-file.md diff --git a/README.md b/README.md index 6e8ee9e..0265d56 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). -_1382 TILs and counting..._ +_1383 TILs and counting..._ --- @@ -474,6 +474,7 @@ _1382 TILs and counting..._ - [Numbers Are Empty](javascript/numbers-are-empty.md) - [Object Initialization With Shorthand Property Names](javascript/object-initialization-with-shorthand-property-names.md) - [Obtain Undefined Value With The Void Operator](javascript/obtain-undefined-value-with-the-void-operator.md) +- [Open Global npm Config File](javascript/open-global-npm-config-file.md) - [Parse A Date From A Timestamp](javascript/parse-a-date-from-a-timestamp.md) - [Pre And Post Hooks For Yarn Scripts](javascript/pre-and-post-hooks-for-yarn-scripts.md) - [Purge Null And Undefined Values From Object](javascript/purge-null-and-undefined-values-from-object.md) diff --git a/javascript/open-global-npm-config-file.md b/javascript/open-global-npm-config-file.md new file mode 100644 index 0000000..6711a40 --- /dev/null +++ b/javascript/open-global-npm-config-file.md @@ -0,0 +1,30 @@ +# Open Global npm Config File + +There are a ton of configuration settings for `npm`. I can open up the global +`npmrc` file where those configs live with the following command: + +```bash +$ npm config edit --global +``` + +This will open up the file in my default editor (e.g. `vim`). + +There are over 100 settings that are commented out with their default values. I +can override these as needed by uncommenting them and setting them to the +desired value. + +There is some useful info in the first few lines: + +``` +;;;; +; npm globalconfig file: /Users/me/.asdf/installs/nodejs/20.10.0/etc/npmrc +; this is a simple ini-formatted file +; lines that start with semi-colons are comments +; run `npm help 7 config` for documentation of the various options +``` + +1. I can see that the location of the file is specific to the version of node + that I current have shimmed. In this case, it's `20.10.0`. If I switch node + versions, there will be a different `envrc` to configure. + +2. I can get more info about these config values by running `npm help 7 config`.