cli icon indicating copy to clipboard operation
cli copied to clipboard

defining config in .sequelizerc does not work

Open ch1ll0ut1 opened this issue 7 years ago • 18 comments
trafficstars

What you are doing?

I try to run the cli with a configured .sequelizerc, but the cli is printing a error:

sequelize: Unknown arguments: config, migrations-path, models-path, seeders-path

.sequelizerc :

var path = require('path')

module.exports = {
  'config':          path.resolve('sequelize.config.js'),
  'migrations-path': path.resolve('src', 'migrations'),
  'models-path':     path.resolve('src', 'models'),
  'seeders-path':    path.resolve('src', 'seeders'),
}

What do you expect to happen?

Successfully loading the config

What is actually happening?

Unknown arguments: config, migrations-path, models-path, seeders-path

Dialect: postgres Sequelize CLI version: 4.0.0 Sequelize version: 4.34.1

ch1ll0ut1 avatar Mar 12 '18 10:03 ch1ll0ut1

I confirm the message being present after updating sequelize-cli from 3.9 to 4. However, it seems that it has no effect on execution results whatsoever. At least migrations and seeds are running as expected. Dialect: mysql, Sequelize CLI v.4 Sequelize v.4.33

AndrewKiri avatar Mar 18 '18 22:03 AndrewKiri

Having the same issue

maZahaca avatar Mar 22 '18 13:03 maZahaca

I'm having the same issue. My versions are: Sequelize CLI [Node: 8.4.0, CLI: 4.0.0, ORM: 4.37.5]

Although downgrading to v3.2.0 of the Sequelize CLI generates the same error: Sequelize CLI [Node: 8.4.0, CLI: 3.2.0, ORM: 4.37.5]

Unknown arguments: config, migrations-path, seeders-path, models-path

BideoWego avatar Apr 05 '18 05:04 BideoWego

Same problem here.

Pedroglp avatar May 07 '18 20:05 Pedroglp

I'm getting "Cannot find "/app/.config/sequelize-config.json". Have you run "sequelize init"?" although the file is there.

EduardsE avatar May 09 '18 10:05 EduardsE

Same problem here.

jilvin avatar Jun 06 '18 08:06 jilvin

I too have found this problem I'm using Sequelize 4.38.0 and Sequelize CLI 4.0.0

yet running sequelize without any options returns a list of options I can use but also returns the following warning:

WARNING: This version of Sequelize CLI is not fully compatible with Sequelize v4. https://github.com/sequelize/cli#sequelize-support

However, when browsing to that link it simply takes you to the Sequelize CLI landing page where no information can be found on the issue of compatibility.

Epyon616 avatar Jul 10 '18 11:07 Epyon616

The reason is that the sequelize-cli cannot recognize .sequelizerc file which is should be under the root directory. My solution to this is you can migrate with commands like below:

cd build/db && sequelize db:migrate --config database.js

Keep in mind:

  1. sequelize-cli is installed globally
  2. database file is under build/db
  3. migrations, models, seeders directory is also under build/db (if not you can also specify them base on under commands)

image

likeconan avatar Sep 12 '18 00:09 likeconan

Move to folder where your project understands with root. As in this example, the project understands the src folder as root. Save the .sequelizerc file to this folder and you're done! :) screenshot from 2019-02-22 00-20-04

heeisenbeergg avatar Feb 22 '19 03:02 heeisenbeergg

I'm totally a newbie on this but I tried a weird way but it worked. In your .sequelizerc file, delete all lines inside the module.exports = {} // Leave it blank then run 'sequelize init' => magic happens. Anyone knows exactly why does this work?

hoangfuongduy avatar Mar 01 '19 15:03 hoangfuongduy

I'm totally a newbie on this but I tried a weird way but it worked. In your .sequelizerc file, delete all lines inside the module.exports = {} // Leave it blank then run 'sequelize init' => magic happens. Anyone knows exactly why does this work?

I tried this too and it worked, Apparently, sequelize does not require you to explicitly define path, once you run the command sequelize init from your root directory it would automatically create those folders from your root directory.

Sojisoyoye avatar Apr 07 '19 08:04 Sojisoyoye

Yep this works for me too...

senth542002 avatar May 09 '19 06:05 senth542002

Still does not work in sequelize 5.5.0.

My folder structure is like /db/migrations, /db/seeds, /db/models. Running commands locally works fine and .sequelizerc recognizes the paths, but when building a docker image the commands fail with the error, "Could not find config.json"

Please help.

My versions are as follows: Sequelize CLI [Node: 12.4.0, CLI: 5.5.0, ORM: 6.0.0]

snetts avatar Jul 19 '19 13:07 snetts

I was having a similar problem and I solved it like so. I had initialized sequelize first built out my models, server, etc. Then, I went back to use a .sequelizerc file and use config.js instead of config.json, that way I could change my database credentials and hide them. I ended up having to go into ./models/index.js and change the following code

const config = require(__dirname + '/../config/config.json')[env];

to:

const config = require(__dirname + '/../config/config.js')[env];

This worked for me, but I don't know if you are having separate issues elsewhere.

shaunwcolley avatar Jul 23 '19 20:07 shaunwcolley

@shaunwcolley While this issue is about the sequelize-cli tool that must be called from the command line, you solved my problem too. Of course require will not react to .sequelizerc. The fact that we both wound up here highlights some confusion resulting from using the (very convenient) models/index.js sample code, and later trying to make more advanced Sequelize changes whose documentation was not written with that sample in mind. Thanks!

MBerka avatar Aug 20 '19 08:08 MBerka

Not working yet:

Sequelize CLI [Node: 12.8.1, CLI: 5.5.1, ORM: 5.21.4]
5.5.1

I'm getting: Unknown argument: config

Any solution?

diegoulloao avatar Feb 15 '20 21:02 diegoulloao

@diegoulloao related to the node version. my problem was fixed

ademilter avatar May 17 '20 09:05 ademilter

I'm facing this issue as well, only when I run sequelize with no arguments (sequelize init works fine)

image

Sequelize CLI [Node: 16.13.0, CLI: 4.1.1, ORM: 6.12.1]

My .sequelizerc

require('@babel/register')
const path = require('path')

module.exports = {
	'config': path.resolve('config', 'sequelize.json'),
	'models-path': path.resolve('src', 'models'),
	'migrations-path': path.resolve('src', 'migrations'),
}

slifty avatar Dec 21 '21 20:12 slifty