ERROR: Error reading "config\config.js". Error: undefined. Migracion con sequelize-cli

Open
#1,516 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
25/100
Issue type
Bug
Clarity
Needs clarification
Activity status
Stale
Tech stack
javascript
Domain
cli, database

Research direction

Start by reproducing the migration failure with the shown config/config.js and .sequelizerc files, then inspect how sequelize-cli loads the configuration. Check the interaction between the project's module settings and the CLI configuration entry point. Done means sequelize-cli reads the configuration without the reported error and can proceed with the migration.

Written by the indexing model from the issue text.

Description

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'),
};

Dominant language
JavaScript
Stars
2.6k
Forks
524
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from sequelize/cli

All issues in sequelize/cli

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.