`sequelize init` writes JSON content into `.js` config file when using `.sequelizerc`
Author: sanskarajputCreated Apr 6, 2026Updated Apr 6, 2026
Issue Creation Checklist
- I understand that my issue will be automatically closed if I don't fill in the requested information
- I have read the contribution guidelines
Bug Description
When using sequelize init with a .js config file path (via .sequelizerc),
the generated config file contains raw JSON content instead of valid JavaScript.
This breaks the dynamic configuration use case documented in the official docs.
Reproducible Example
- Create a
.sequelizercfile:
const path = require('path');
module.exports = {
config: path.resolve('config', 'config.js'),
};
- Run:
npx sequelize-cli init
What do you expect to happen?
config/config.js should be generated with valid JS content:
module.exports = {
development: {
username: 'root',
password: null,
database: 'database_development',
host: '127.0.0.1',
dialect: 'mysql'
}
}
What is actually happening?
config/config.js is created but filled with raw JSON content:
{
"development": {
"username": "root",
"password": null,
"database": "database_development",
"host": "127.0.0.1",
"dialect": "mysql"
}
}
A .js file containing JSON is invalid as a dynamic configuration file and
breaks the use case documented here:
https://sequelize.org/docs/v6/other-topics/migrations/#dynamic-configuration
Environment
- Sequelize-cli version: 6.6.5
- Node.js version: 20.19.4
- If TypeScript related: N/A
- Database & Version: N/A
- Connector library & Version: N/A
Would you be willing to resolve this issue by submitting a Pull Request?
- Yes, I have the time and I know how to start.
Source: sequelize/cli