Make sure you have ts-node installed: npm install ts-node
This creates a .ts file in migrations directory
npm run knex:migrate:make -- some-migration-name
npm run knex:migrate:latest
npm run knex:migrate:rollback
knexfile.ts
requiresrequire('ts-node/register');
to work.- ES6/ES2015 module syntax does not work in knexfile or in any files that it
require()
s
Now you can specify to knex generate ts files on
knexfile.ts
.This makes it easier than always to specifying the
-x ts
flag.In case you're interested, I set up this example project: https://github.com/jfollmann/knex-migrations-ts
Thank you for sharing this note.