Ok, so this is either very weird or I'm not understanding something that is happening. I am trying to load the sequelize library in node.
when trying to connect I'm using the CLI generated index.js file however this line:
if (config.use_env_variable) {
console.log('i ran');
var sequelize = new Sequelize(process.env[config.use_env_variable], config);
} else {
var sequelize = new Sequelize(config.db.database, config.db.username, config.db.password, {
dialect:config.db.dialect});
}
is giving me this error:
Cannot read property 'use_env_variable' of undefined
as far as I know that line is meant to see if this even returns anything so I don't understand why this is throwing that error?
UPDATE
config is invoked in a line above it, the whole file up to that point is:
'use strict';
var fs = require('fs');
var path = require('path');
var Sequelize = require('sequelize');
var basename = path.basename(__filename);
const config = require(path.join(__dirname,'../config/config.js'));
const db = {};
console.log(config);
if (config.use_env_variable) {
console.log('i ran');
var sequelize = new Sequelize(process.env[config.use_env_variable], config);
} else {
var sequelize = new Sequelize(config.db.database, config.db.username, config.db.password, {
dialect:config.db.dialect});
}
UPDATE added console.log of config on working version