Using environment variables in your node script

It’s as easy as this. In your code, use process.env.SOMETHING. And when you run your script with node theScript.js set the environment variables first. So it’ll be something like:

SOMETHING=the-secret-password node theScript.js

That’s it! Oh, don’t put spaces around the equals sign. Doesn’t work.

Read more:

Blog posts

Today I learnt