I am moving an Express app across from CommonJS require
syntax to the ES6 module import
syntax. This is fine until I try and use dotenv
to load my environment variables and every time I try to access these variables they come back as undefined.
app.js
// importing environmental variables
import dotenv from 'dotenv';
dotenv.config();
import express from 'express';
let x = process.env.David;
console.log(x);
.env
David = test