question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Required configuration option 'client' is missing.

See original GitHub issue

Documentation states:

You can even use knex without a connection, just for its query building features.

Though running direct example from docs:

const knex = require(‘knex’)({});

Throws error:

> knex = require('knex')({})
Error: knex: Required configuration option 'client' is missing.
    at new Client (/home/ginden/.../node_modules/knex/lib/client.js:108:11)
    at Knex (/home/ginden/.../node_modules/knex/lib/index.js:60:34)
    at repl:1:23

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

4reactions
Haisum92commented, Nov 1, 2019

@Ginden , it raised due to two reasons at my side and so sharing for ease Error: knex: Required configuration option ‘client’ is missing.

  1. Wrong environment name in the knexfile.js. In my .env NODE_ENV = development and at knexfile.js there was no entry in it

     module.exports = {
    
      test: {
        client: config.DB_DIALECT,
        connection: {
          host      : process.env.DB_HOST,
          user      : process.env.DB_USERNAME,
          password  : process.env.DB_PASSWORD,
          database  : (process.env.DB_NAME == "test") ? process.env.DB_NAME_TEST : process.env.DB_NAME,
          timezone  : config.GLOBAL_TIME_ZONE
        },
        migrations: {
          tableName: migrationTable
        }
      },
      Local: {
        client: config.DB_DIALECT,
        connection: {
          host      : process.env.DB_HOST,
          user      : process.env.DB_USERNAME,
          password  : process.env.DB_PASSWORD,
          database  : (process.env.DB_NAME == "test") ? process.env.DB_NAME_TEST : process.env.DB_NAME,
          timezone  : config.GLOBAL_TIME_ZONE
        },
        migrations: {
          tableName: migrationTable
        }
      },
      
      staging: {
        client: config.DB_DIALECT,
        connection: {
          host      : process.env.DB_HOST,
          user      : process.env.DB_USERNAME,
          password  : process.env.DB_PASSWORD,
          database  : process.env.DB_NAME,
          timezone  : config.GLOBAL_TIME_ZONE
        },
        migrations: {
          tableName: migrationTable
        }
      },
    
      production: {
        client: config.DB_DIALECT,
        connection: {
          host      : process.env.DB_HOST,
          user      : process.env.DB_USERNAME,
          password  : process.env.DB_PASSWORD,
          database  : process.env.DB_NAME,
          timezone  : config.GLOBAL_TIME_ZONE
        },
        migrations: {
          tableName: migrationTable
        }
      }
    
    };
    
2. Wrong client name at configrations
client: config.DB_DIALECT, // either key doesn't exits or wrong name at config file 
3reactions
elhigucommented, Apr 20, 2017
Read more comments on GitHub >

github_iconTop Results From Across the Web

Knex required configuration option 'client' is missing error
The problem is that your typescript export default is not supported by knex cli by default. ... As you can see, you can...
Read more >
Knex required configuration option 'client' is missing error
The problem is that your typescript export default is not supported by knex cli by default. ... As you can see, you can...
Read more >
Error with knex self-hosted - Installation - Ghost Forum
Error: knex: Required configuration option 'client' is missing. ... It looks like you have not properly configured the database property in your ...
Read more >
tgriesser/knex - Gitter
node -r dotenv/config node_modules/.bin/knex seed:run Using environment: ... throw new Error(`knex: Required configuration option 'client' is missing.`);.
Read more >
heroku knex required configuration option client is missing,
heroku knex required configuration option client is missing ... Most likely the default used by Knex is not right so it's best to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found