Skip to content

[DOCS] npm_config_userconfig vs NPM_CONFIG_USERCONFIG when referred as environment variable #4891

@ryenus

Description

@ryenus

Is there an existing issue for this?

  • I have searched the existing issues

This is a CLI Docs Problem, not another kind of Docs Problem.

  • This is a CLI Docs Problem.

Description of Problem

This is about the ambiguity regarding the case of the environment variables.

If we take NPM_CONFIG_USERCONFIG as the example.
Here in the docs, it's referred as NPM_CONFIG_USERCONFIG, in uppercase:

per-user configuration file (defaults to $HOME/.npmrc; configurable via CLI
option --userconfig or environment variable $NPM_CONFIG_USERCONFIG)

However later in the same docs, and in the source, it's referred as npm_config_userconfig, in lowercase:

This may be overridden by the npm_config_userconfig environment variable
or the --userconfig command line option

I understand that both uppercase NPM_CONFIG_USERCONFIG and lowercase npm_config_userconfig work, because internally the environment variable names are converted to lowercase.

But what happens if both NPM_CONFIG_USERCONFIG and npm_config_userconfig are set? Or even if there's alsoNPM_CONFIG_userconfig? I haven't done a thorough testing but I bet the result would be interesting and/or surprising.

Can we follow the convention and always refer to environment variable names in uppercase? That is already the de-facto standard. Thank you!

Potential Solution

Always use environment variables in uppercase.

Affected URL

https://docs.npmjs.com/cli/v8/using-npm/config#userconfig

Metadata

Metadata

Assignees

No one assigned

    Labels

    Documentationdocumentation related issueNeeds Triageneeds review for next steps

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions