Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are Node js environment variables written in all caps and underscores?

From http://www.meteorpedia.com/read/Environment_Variables, "... getting and setting of environment variables is via process.env. By convention, environement variables are in all caps, with words separated by underscores, LIKE_THIS."

And https://codeburst.io/how-to-easily-set-up-node-environment-variables-in-your-js-application-d06740f9b9bd: "You can use whatever names you’d like, but the general naming convention is all-caps with underscores between words."

Why? Is there any legitimate argument against using camel case?

like image 241
asparism Avatar asked Oct 14 '17 18:10

asparism


People also ask

Why are environment variables all caps?

By convention, environment variables ( PAGER , EDITOR , ...) and internal shell variables ( SHELL , BASH_VERSION , ...) are capitalized. All other variable names should be lower case. Remember that variable names are case-sensitive; this convention avoids accidentally overriding environmental and internal variables.

Do environment variables need to be all caps?

By convention, environment variables are written in UPPERCASE while shell variables usually have lowercase names.

Do we need to set environment variables for Node JS?

You really do not need to set up your own environment to start learning Node. js. Reason is very simple, we already have set up Node.


1 Answers

In fact, these are not environment variables, but environment constants in the scope of your app.
It's a convention to name constants in capital letters.

The underscore just makes it more readable.

You can still use camelCase if you prefer, it's a matter of choice.

like image 197
TGrif Avatar answered Oct 19 '22 22:10

TGrif