Variable Location
OSX The default location for custom environmental variables in OSX the .bash_profile
file.
~/.bash_profile
To list all the variables that are being used by your system use the printenv
command.
➜ ~ printenv
Variable | Description |
---|---|
$PATH | Semicolon delimited list of directories |
$HOME | The path to the home directory |
Remember: Environment variables can have scope and a value, just like any other variable.
Variable Assignment
When writing your application you might want to set or read an environment variable. One of the most common custom variables used in ExpressJS is the NODE_ENV
variable. This is a custom variable that is used to distinguish between production and development environments.
Setting a variable: To set the variable use the command line.
export NODE_ENV=development
Reading a variable: To read the variable using the command line.
echo NODE_ENV
Reading a variable: To read the variable using JavaScript.
console.log(process.env.NODE_ENV);
Summary
Remember it’s your personal development environment, it needs to be as unique as you. You will be using it hours on end if you decide to use windows great if you go with Linux great, or OSX then great.
I always had a passion for the field of STEM (Science, Technology, Engineering, and Math) and I knew I wanted to do something to make a difference in the world. I just didn’t know where to start. I was an immigrant in a new country, grew up in a tough environment, and wasn’t sure how… Read More