You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1. 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'.
2. What are you doing?
I have a 2 file config:
config.sequelize.js
config.json
--> I want to use the config.sequelize.js file to use environment variables to secure information.
I config file .sequelizerc with path config.json --> it's working
In config.sequelize.js you have development defined, instead of dev which is the environment that is used. That's why it doesn't know which dialect you want to use
Trong config.sequelize.js bạn đã developmentxác định, thay vào devđó là môi trường được sử dụng. Đó là lý do tại sao nó không biết bạn muốn sử dụng phương ngữ nào
Oh shit, Thank you very much, I have fixed it. What a silly mistake 🤣🤣🤣
1. 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'.
2. What are you doing?
I have a 2 file config:
--> I want to use the config.sequelize.js file to use environment variables to secure information.
I config file .sequelizerc with path config.json --> it's working
$ npx sequelize-cli db:migrate Sequelize CLI [Node: 20.14.0, CLI: 6.6.2, ORM: 6.37.3] Loaded configuration file "src\config\config.json". Using environment "dev". == 20240629071618-create-user: migrating ======= == 20240629071618-create-user: migrated (0.063s)
But, I use file config.sequelize.js , I get an error:
$ npx sequelize-cli db:migrate Database Type: mysql Sequelize CLI [Node: 20.14.0, CLI: 6.6.2, ORM: 6.37.3] Loaded configuration file "src\config\config.sequelize.js". ERROR: Dialect needs to be explicitly supplied as of v4.0.0
3. Additional context
3.1. File config/config.json
{ "dev": { "username": "root", "password": "", "database": "db2_dev", "host": "127.0.0.1", "port": 6611, "dialect": "mysql" }, "test": { "username": "root", "password": "", "database": "db2_test", "host": "127.0.0.1", "port": "3306", "dialect": "mysql" }, "production": { "username": "root", "password": "", "database": "db2_prod", "host": "127.0.0.1", "port": "3306", "dialect": "mysql" } }
3.2. File config.sequelize.js
`
require("dotenv").config();
console.log("Database Type: ", process.env.DB_TYPE);
module.exports = {
development: {
username: process.env.DEV_DB_USERNAME,
password: process.env.DEV_DB_PASSWORD,
database: process.env.DEV_DB_NAME,
host: process.env.DEV_DB_HOST,
port: process.env.DEV_DB_PORT,
dialect: process.env.DB_TYPE,
},
test: {
username: process.env.DEV_DB_USERNAME,
password: process.env.DEV_DB_PASSWORD,
database: process.env.DEV_DB_NAME,
host: process.env.DEV_DB_HOST,
port: process.env.DEV_DB_PORT,
dialect: process.env.DB_TYPE,
},
production: {
username: process.env.DEV_DB_USERNAME,
password: process.env.DEV_DB_PASSWORD,
database: process.env.DEV_DB_NAME,
host: process.env.DEV_DB_HOST,
port: process.env.DEV_DB_PORT,
dialect: process.env.DB_TYPE,
},
};
`
3.3. File .sequelizerc
`
// .sequelizerc
require("babel-register");
require("dotenv").config();
const path = require("path");
// const { development } = require("./src/config/config.sequelize.js");
module.exports = {
env: process.env.NODE_ENV || "dev",
// config: JSON.stringify(development),
config: path.resolve("./src/config/", "config.sequelize.js"),
};
`
4. Environment
The text was updated successfully, but these errors were encountered: