npm - How do I set an environment variable? -


in bash can see npm environment variables npm run env. user=brianmackey 1 such environment variable. how can set environment variable, user=billybob?

i know can use npm config set <key> <value> [--global]. key+value always/in case environment variable? can set environment variables in session?

single command

if want set environment variables single node command, can this:

$ user=billybob node server.js 

loaded each session

if want permanently set environment variable user, edit ~/.bash_profile , add following line:

export user="billybob" 

this automatically set given environment variable each time create new terminal session.

existing entire current session

lastly, if want set environment variable current session, run it's own command:

$ user=billybob $ node app.js # user billybob $ node app.js # user still billybob 

when exit session, these temporarily set environment variables cleared.


Popular posts from this blog