Accessing ENV var in different files in Node.js using dotenv
<p>I have a simple app I'm working on that uses the Google Maps API, and Darksky API; I've installed dotenv to handle hiding the keys for both. After following the Docs I was able to make this work but only in the file where dotenv in being required (app.js). I need access to the ENV variables in my footer.ejs file, and a weather.js file but process.env is not defined in them. Do I have to export dotenv? How do this? Thanks, in advance.</p>

<h2>app.js</h2>

<pre><code>var express = require('express'),
Dotenv = require('dotenv').config(),
app = express(),
bodyParser = require('body-parser'),
mongoose = require('mongoose');

mongoose.connect(process.env.DB_URL);
app.use(bodyParser.urlencoded({extended: true}));
app.set('view engine', 'ejs');
app.use(express.static(__dirname + '/assets'));

// HomePage
app.get('/',function(req, res){
  res.render('home');
});

app.listen(process.env.PORT || process.env.LOC_PORT,function(err){
  if (err) return console.log(err);
  console.log('Server Running: '+ process.env.LOC_PORT);
});
</code></pre>