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

Add Open Global npm Config File as a JavaScript TIL

This commit is contained in:
jbranchaud
2024-02-28 12:40:48 -06:00
parent 24278989d8
commit 9a9cebaa11
2 changed files with 32 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).
_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)

View File

@@ -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`.