cli
cli copied to clipboard
.sequelizerc no longer accept .ts extension for config
What you are doing?
I have a .ts config for database connection which used to work for version 6.2.0 and below. Since I upgraded to latest version, cli can't work with .ts anymore and it is throwing error
ts-node node_modules/.bin/sequelize db:migrate
.sequelizerc content
const path = require('path');
module.exports = {
'migrations-path': path.resolve('./migrations'),
'config': path.resolve('./src/config', 'database.ts')
}
What is actually happening?
Sequelize CLI [Node: 17.5.0, CLI: 6.4.1, ORM: 6.18.0]
ERROR: Error reading "src/config/database.ts". Error: TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" for /Users/nguyentrungluu/Documents/self-learn/nestjs/src/config/database.ts
__Dialect: postgres __Sequelize CLI version:6.4.1
I believe that's because we load files using import()
You'll need to use ts-node's esm loader on this
Is there any update?
Our recommendation is currently still to either:
- transpile your migrations before executing them with sequelize-cli (highly recommended)
- run the cli using ts-node-esm
We're open to PRs and propositions to improve the solution
Can you use npx sequelize-cli db:migrate --url 'mysql://root:password@mysql_host.com/database_name'
The issue seems to have started in sequelize-cli v6.4.0