I\'m looking to use an environment variable inside of the config.json file of my project using sequelize. I\'m using dotenv to set environment variables locally. My config.json
Assuming you're using Passport, Sequelize, MySql:
On the index.js file setup through sequelize, look for this line:
var sequelize = new Sequelize(config.database, config.username, config.password, config);
Try changing it to:
var sequelize = new Sequelize(process.env.DB_DATABASE, process.env.DB_USERNAME, process.env.DB_PASSWORD, config);
Your .env should have:
DB_USERNAME:root (or whatever your username is)
DB_PASSWORD:NYB (whatever your password is)
DB_DATABASE:whatever_your_dbNameis_db
Last, depending on how your passport strategy is setup, look for something that says:
user.sequelize.sync().then(function(){
}...
You are going to need to place the: database:process.env.DB_DATABASE
user.sequelize.sync().then(function(){
database:"process.env.dbn"
}...
This means that you should remove that key:value from the config.json.
It should be good to go and you will not have to convert anything. Sequelize will take care of all of that.