Getting ERROR: Error parsing url: undefined when trying to run migrations with Sequelize

I’m creating a Node.js/Express.js app with Sequelize as my ORM. This is the tutorial I’m following. I’m having trouble migrating my tables onto my Azure SQL database.

My config/config.json file is as such:

{
    "development" : {
       "use_env_variable" : "DATABASE_URL",
       "dialect" : "mssql"
    }
}

My .env file is as such:

DATABASE_URL=<connection string here>

These are being called by this code in models/index.js:

'use strict';

var fs        = require('fs');
var path      = require('path');
var Sequelize = require('sequelize');
var basename  = path.basename(module.filename);
var env       = process.env.NODE_ENV || 'development';
var config    = require(__dirname + '/../config/config.json')[env];
var db        = {};

if (config.use_env_variable) {
  var sequelize = new Sequelize(process.env[config.use_env_variable]);
} else {
  var sequelize = new Sequelize(config.database, config.username, config.password, config);
}

I have require('dotenv').config() in my main file app.js. My understanding was that the dotenv package exports all of my .env variables throughout my project.

When I try running node_modules/.bin/sequelize db:migrate in the terminal, I get

ERROR: Error parsing url: undefined

Why is it coming back as undefined?

Here is my file structure in case it helps.

enter image description here

140 thoughts on “Getting ERROR: Error parsing url: undefined when trying to run migrations with Sequelize”

  1. Pingback: viagra online usa
  2. Pingback: canada viagra
  3. Pingback: viagra generic
  4. Pingback: buy cialis
  5. Pingback: cialis 5 mg
  6. Pingback: sildenafil
  7. Pingback: buy viagra
  8. Pingback: buy cialis pills
  9. Pingback: viagra buy
  10. Pingback: order cialis
  11. Pingback: viagrasao.com
  12. Pingback: teva tadalafil
  13. Pingback: walgreens cialis
  14. Pingback: buy herb viagra
  15. Pingback: sildenafil 20mg
  16. Pingback: natural viagra
  17. Pingback: sildenafil viagra
  18. Pingback: viagra wirkung
  19. Pingback: hims viagra
  20. Pingback: whats viagra
  21. Pingback: viagra cost
  22. Pingback: viagra cialis
  23. Pingback: herbal viagra
  24. Pingback: viagra substitute
  25. Pingback: cialis for bph
  26. Pingback: cialis com

Leave a Comment