-
-
Notifications
You must be signed in to change notification settings - Fork 527
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error: Dialect needs to be explicitly supplied as of v4.0.0 #1068
Comments
I lied when I said I didn't have time and wouldn't even know how to start, I wouldn't let this beat me. I've created a pull request, as above, that will allow objects to be exported from .sequelizerc. In my case, and with the pull request, the below .sequelizerc now meets my expected outcome: const path = require('path');
const { database } = require('./config/config');
module.exports = {
'config': database,
'models-path': path.resolve('./models'),
'seeders-path': path.resolve('./seeders'),
'migrations-path': path.resolve('./migrations')
}; |
Use this |
Hello, @Asharudheen-VNC , i have the same issue, where do I use your suggestion ? |
Making use of .sequelizerc file , which am currently having have not solved the problem. Thank you for making a pull request on this |
@iamgabrielsoft I have the same problem |
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. 🙂 |
Not stale. |
Some news? I have the same issue when running with pm2. Running with npm start ou nodemon works fine. Some clue? |
This issue has been automatically marked as stale because it has been open for 14 days without activity. It will be closed if no further activity occurs within the next 14 days. If this is still an issue, just leave a comment or remove the "stale" label. 🙂 |
Check project .env file if you are using environment variables, I forgot to set dialect after setting-up .env file properly its working fine |
I had this issue as well, somewhere sequelize is looking for a development environment, once i added development this error went away. My config file now shows development, test, and production options. |
The default environment that the CLI uses is |
Tentei todas essas opções e o erro permanece, o que poderia tentar? |
Esse erro sumiu depois de colocar esse trecho no index.js const dbConfig = require("../config/db.config")['development'] |
Hello, Does someone knows how to make the import version of this: |
Arquivo config.js Arquivo .env |
Same issue |
Basically in this issue Sequelize cannot find the environment on which it have to perform action. By default sequelize look for value of NODE_ENV like if you have set "development" in your NODE_ENV , sequelize will look for "development" in object define in config.js file. In your case set (in .env file) in .env fileNODE_ENV= development in config.jsrequire('dotenv').config() |
thanks bro, it's work for me use typescript in express js maybe some one need, this my config/db.ts `import dotenv from 'dotenv' dotenv.config() let dbName = process.env.database_production const env = process.env.NODE_ENV const db = new Sequelize(dbName as string, username as string, password, { export default db |
Just had this same issue. Resolved by following this steps. Thanks! |
I did all of those solutions you suggested, but none working.😭😭 |
Can you explain more what is your issue? |
Issue Description
'Error: Dialect needs to be explicitly supplied as of v4.0.0' is thrown when initialising sequelize via a destructured property whilst running 'npx sequelize-cli db:migrate'.
What are you doing?
I have a config.js which merges different sections of a config.json dependent on the environment so as to prevent repeated configurations, it exports the final, merged, configuration. Within the final configuration is a sub object of 'dev' called 'database'.
Sequelize's .sequelizerc is unable to process this as the config paramter expects a file path, not an object and thus is not using the 'database' object and instead is using the whole object. When trying to run 'npx sequelize-cli db:migrate' the error above is thrown.
If I change config.js to instead export 'finalConfig.database', 'npx sequelize-cli db:migrate' works without issue.
What do you expect to happen?
For 'npx sequelize-cli db:migrate' to migrate successfully.
What is actually happening?
An error is thrown.
Additional context
config/config.json
Works
config/config.js
Does not work
config/config.js
Environment
Issue Template Checklist
How does this problem relate to dialects?
Would you be willing to resolve this issue by submitting a Pull Request?
The text was updated successfully, but these errors were encountered: