mkConfigObj Knex error

Asked

Viewed 591 times

0

I’m creating an Migration from the Knex, but when I run the command

npx knex migrate:latest --knexfile knexfile.ts migrate:latest

I get the following error:

No Configuration file found and no commandline Connection Parameters passed at mkConfigObj

Already I stopped the file that the error points, are some settings of CLI.

My knexfile.ts

import path from 'path';

module.exports = {
    client: 'sqlite3',
    connection: {
        filename: path.resolve(__dirname, 'src', 'database', 'database.sqlite')
    },

    migrations:{
        directory: path.resolve(__dirname, 'src', 'database', 'migrations')
    }
};
  • 1

    The knexfile.ts file has to be at the root of the project. It is likely that yours is not.

  • I’ve had this problem before, and it was actually the wrong way of knexfile.ts.

1 answer

2


Look, I had the same error. was pq was in the wrong directory. Enter the back-end directory, and run the dnv command that is right.

  1. npm install knex
  2. npm install sqlite3 (if that’s what you’re using)
  3. npx knex migrate:Latest --knexfile knexfile.ts migrate:Latest

It worked for me.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.