Node.js Environment Variables In Tasks


We may need to use some environment variables - for example to authentificate our calls to an API.

The recommended way is to use a .env file inside your Zenaton project to store your environment variables. Add the dotenv lib in your package.json file:

{
  "dependencies": {
    "zenaton": "^0.8.0",
    "dotenv": "^6.2.0"
  }
}

and ensure that your .env file is read in your boot.js file:

require('dotenv').config()

Then, your Node.js environment variables will be available through process.env.