I have a javascript file defined in a class inside an express app.
import dotenv from 'dotenv';
dotenv.config();
class Settings {
static getSettings() {
const activeEnvironment = process.env.NODE_ENV;
console.log('active ', activeEnvironment)
const settings = {
development: {
databaseName: 'foods',
},
production: {
databaseName: 'foods',
},
test: {
databaseName: 'testdb'
}
};
settings[activeEnvironment] // returns undefined
return settings[activeEnvironment];
}
}
export default Settings;
But the problem I have is that settings[activeEnvironment] returns undefined. I have correctly exported NODE_ENV in my start script set NODE_ENV=production & node --require @babel/register ./bin/www
Anyone can point me on what I'm doing wrong. I'm a bit new to javascript.
Thank you.