-
-
Notifications
You must be signed in to change notification settings - Fork 526
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
ERROR: Error reading "config\config.js". Error: undefined. Migracion con sequelize-cli #1516
Comments
Note that the configuration file .sequelizerc uses commonjs, if possible change your project to commonjs Can you add error message and trace? |
Gracias por tu respueta, Si, lo cambie a commonjs y puedo aun autenticarme sin problemas, ahora arroja un problema sobre el dialecto : "ERROR: The dialect [object Object] is not supported. Supported dialects: mssql, mariadb, mysql, oracle, postgres, db2 and sqlite.", aun cuando lo estoy definiendo en mi archivo de configuracion. `const dotenv = require("dotenv") const development = new Sequelize({ module.exports = development` |
Your sequelize-cli configuration file module.exports = {
development: {
username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
host: process.env.DB_HOST,
port: process.env.DB_PORT,
dialect: 'postgres',
},
test: {
username: 'root',
password: null,
database: 'database_test',
host: '127.0.0.1',
dialect: 'postgres',
},
production: {
username: 'root',
password: null,
database: 'database_production',
host: '127.0.0.1',
dialect: 'postgres',
},
}; Notice that a Sequelize instance is not used |
Bien, Si lo hago de esa forma, como tendria que llamar a "Developmet" en mi index para cargar las base de datos? gracias. |
Finalmente lo pude hacer, cambie a module.exports mi config.js y agregue un archivo de configuracion mas db.js en la carpeta config que contiene:
Luego lo llamo desde mi index:
Por alguna razon parece que el Sequelize no toma bien las variable de entorno .env, con esta configuracion funciona la autenticacion y la migracion. |
There are two configurations, one for your app to listen to requests and another to execute the sequelize-cli commands |
Hola a todos,
Tengo un problema al ejecutar la migracion con sequelize-cli, recibo el mensaje de error de lectura en el archivo config.js.
Tengo configurado variables de entorno(.env) en la raiz de mi proyecto, no tengo problemas para autenticarme a mi base de datos cuando hago "npm run dev". Estoy trabajado con modulos para las importaciones ("type": "module",).
Agradeceria toda ayuda que sea posible estoy estancado en esto.
gracias.
Mis rutas de directorios:
carpeta raiz
config
- config.js
db
- migrations
- model
- seeders
.env
.sequelizerc
app.js
index.js
...
/* package.json */
"type": "module",
"dependencies": {
"dotenv": "^16.4.5",
"pg": "^8.12.0",
"sequelize": "^6.37.3"
}
"devDependencies": {
"sequelize-cli": "^6.6.2"
}
/* config.js */
import dotenv from "dotenv"
import { Sequelize } from "sequelize"
dotenv.config()
export const development = new Sequelize({
username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
host: process.env.DB_HOST,
port: process.env.DB_PORT,
dialect: "postgres",
});
export const test = new Sequelize({
username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
host: process.env.DB_HOST,
port: process.env.DB_PORT,
dialect: "postgres",
});
export const production = new Sequelize({
username: process.env.DB_USERNAME,
password: process.env.DB_PASSWORD,
database: process.env.DB_DATABASE,
host: process.env.DB_HOST,
port: process.env.DB_PORT,
dialect: "postgres",
});
/* .sequelizerc*/
const path = require('path');
module.exports = {
config: path.resolve('config', 'config.js'),
'models-path': path.resolve('db', 'models'),
'seeders-path': path.resolve('db', 'seeders'),
'migrations-path': path.resolve('db', 'migrations'),
};
The text was updated successfully, but these errors were encountered: