Coder Social home page Coder Social logo

Comments (11)

saeidfiy avatar saeidfiy commented on June 12, 2024 3

I have same issue

Sequelize CLI [Node: 12.16.1, CLI: 5.5.1, ORM: 5.22.3]

Loaded configuration file "config\config.json".
Using environment "development".

ERROR: Error parsing url: undefined


from cli.

zkinsk avatar zkinsk commented on June 12, 2024 1

@ArthurGuez So in the intial example:

production: {
    use_env_variable: process.env.DATABASE_URL,
    dialect: 'postgres',
    dialectOptions: {
      ssl: {
        require: true,
        rejectUnauthorized: false, // <<<<<<< YOU NEED THIS TO FIX UNHANDLED REJECTION 
      },
    },
  },

I instead did this:

production: {
    use_env_variable: DATABASE_URL,
    dialect: 'postgres',
    dialectOptions: {
      ssl: {
        require: true,
        rejectUnauthorized: false, // <<<<<<< YOU NEED THIS TO FIX UNHANDLED REJECTION 
      },
    },
  },

Because you are already saying find this as an environment variable with use_env_variable

from cli.

ArthurGuez avatar ArthurGuez commented on June 12, 2024 1

Thanks @zkinsk :)

It's working for me now 👍

from cli.

Juan321654 avatar Juan321654 commented on June 12, 2024 1

I found the solution to this stackoverflow question at https://stackoverflow.com/questions/49988002/getting-error-error-parsing-url-undefined-when-trying-to-run-migrations-with-s. In short, the .env file is not being loaded correctly by sequelize. To fix this issue, create a file in the root folder called .sequelizerc. Then, inside this file, add the following code. I changed it back to json because the original stackoverflow post was using a js file in the config folder.

// .sequelizerc
require("dotenv").config(); // <- require this here

// ...Any aditional configuration for sequelize-cli like custom folders for models and migrations
const path = require("path");
module.exports = {
  config: path.resolve("config", "config.json"),
  "models-path": path.resolve("models"),
  "seeders-path": path.resolve("seeders"),
  "migrations-path": path.resolve("migrations"),
};

from cli.

bozzmob avatar bozzmob commented on June 12, 2024

I am facing the same issue.


internal/validators.js:120
    throw new ERR_INVALID_ARG_TYPE(name, 'string', value);
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The "url" argument must be of type string. Received undefined
    at validateString (internal/validators.js:120:11)
    at Url.parse (url.js:159:3)
    at Object.urlParse [as parse] (url.js:154:13)
    at new Sequelize (/mnt/d/work/roughwork/backend/node_modules/sequelize/lib/sequelize.js:185:28)
    at Object.<anonymous> (/mnt/d/work/roughwork/backend/src/sequelize.js:11:19)
    at Module._compile (internal/modules/cjs/loader.js:1137:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1157:10)
    at Module.load (internal/modules/cjs/loader.js:985:32)
    at Function.Module._load (internal/modules/cjs/loader.js:878:14)
    at Module.require (internal/modules/cjs/loader.js:1025:19) {
  code: 'ERR_INVALID_ARG_TYPE'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `node src/server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

from cli.

zkinsk avatar zkinsk commented on June 12, 2024

This has worked for me.

use_env_variable: DATABASE_URL,

I don't think you need process.env as you are already declaring use_env_variable

from cli.

agus7fauzi avatar agus7fauzi commented on June 12, 2024

i have no ide, anyone can give other solution?

from cli.

ArthurGuez avatar ArthurGuez commented on June 12, 2024

This has worked for me.

use_env_variable: DATABASE_URL,

I don't think you need process.env as you are already declaring use_env_variable

Could you be more specific please?
Where did you use : use_env_variable: DATABASE_URL ?
Thanks

from cli.

github-actions avatar github-actions commented on June 12, 2024

This issue has been automatically marked as stale because it has been open for 7 days without activity. It will be closed if no further activity occurs. If this is still an issue, just leave a comment or remove the "stale" label. 🙂

from cli.

amauryplayero avatar amauryplayero commented on June 12, 2024

I am having the same issue

from cli.

ephys avatar ephys commented on June 12, 2024

Looking into sequelize-cli's source code, use_env_variable must be the name of the environment variable, as a string. So to fix the above example:

production: {
  use_env_variable: 'DATABASE_URL',
  dialect: 'postgres',
  dialectOptions: {
    ssl: {
      require: true,
      rejectUnauthorized: false, // <<<<<<< YOU NEED THIS TO FIX UNHANDLED REJECTION 
    },
  },
},

from cli.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.