
I think the need for this is reduced somewhat by careful use of scopes and modifying npm to not remove comments from config files.Īll of the above is most likely going to remain out of scope for the CLI team for the next 6-12 months, so I’m going to close this feature request. Not as elegant, but still relatively straightforward.
It’s out of scope for npm to pull in the behavior of something like npmrc, but do be aware that the command-line option -userconfig is available and can be used in aliases and shell scripts to switch between multiple npmrc files at runtime. A change to make that non-destructive (and maybe to handle npmrc environment variable expansion #10782, which is another symptom of how the config serialization currently works) would be extremely welcome). Config file parsing and storing is handled by a dependency, and making it preserve comments is tricky, but given that the file format supports comments (unlike the JSON used by our friend package.json), the CLI shouldn’t be stomping on those values. It’s not easy to make it so that editing the config preserves the existing formatting and comments in the config files, but that doesn’t mean it shouldn’t be done. The CLI would need a new option to tell npm config to modify the per-package configuration, but beyond that, the existing code should make it pretty clear how to add the new type of editing. npm config set and npm config set -g only allow you to edit two of those four kinds of files I agree that if npm is going to support per-package configuration, it should be configurable via the CLI.
npmrc at ”$(pwd)/.npmrc”, a per-user file at ”$HOME/.npmrc” (what calls “the global config”), a global file installed at ”$(npm -g prefix)/etc/npmrc”, and a special “ npmrc” bundled into the CLI package itself (used to ensure that things stay installed in the correct places on Windows).
npmrc files evaluated by npm's configuration framework: a per-package.
There are actually four different kinds of. There's even more going on in this issue than there appears at first: