NodeJS project: message: "knex: Required configuration option 'client' is missing."

======== TEMPLATE BUG FORM ========

Wappler Version : 3.5.1
Operating System : Mac, NodeJS, MySql8

Expected behavior

I should be able to simply deploy to my staging environment (not confident in deploying to production!).

…YOUR TEXT HERE …

Actual behavior

Almost every time I get an error when deploying to staging, with the connection to the DB. This is the latest. I know how to fix this, and I have fixed this previously by changing the ‘type’ to ‘client’ in the db.json.

But then when I switch between targets, it seems to return itself to ‘type’.

My local db.json:

{
  "name": "db",
  "module": "dbconnector",
  "action": "connect",
  "options": {
    "client": "mysql",
    "connection": {
      "host": "db",
      "port": 3306,
      "user": "db_user",
      "password": "...",
      "database": "..."
    }
  }
}

My remote (staging) db.json:

{
  "name": "db",
  "module": "dbconnector",
  "action": "connect",
  "options": {
    "type": "mysql",
    "connection": {
      "host": "...",
      "port": "...",
      "user": "root",
      "password": "...",
      "database": "..."
    }
  }
}

Note that the remote (staging) has ‘type’ instead of ‘client’. I HAVE previously changed, and saved this and deployed to get this working, thanks to @patrick identifying the issue. However, for whatever reason Wappler has changed it back to ‘type’.

The db connection file per targets are stored into:

.wappler/targets/your_staging_target/app/modules/connections/db.json

Somehow it is corrupted.

Maybe just select tge staging target and edit the db connection settings for that target in server connect. See if it saves fine.

You can edit those in the new global db connections in server connect, just make sure tge right target is selected.

When you switch targets the file is copied from there and becomes current.

Thanks @George - tried that, and no luck. I have to check the db.json file each time I switch target and change it from type to client manually at the moment to ensure it doesn’t fail

Could you just delete it from the .Wappler/targets folder and just generate it again?

Otherwise indeed you keep loping tge old one

Sure happy to try that, to confirm, delete which one? the one on staging?

Yes

Hey @George, that didn’t end up working - but did spur some inspiration. I checked both the db.json file in ‘databases’ folder as well as the ‘connections’ folder for the appropriate target. the db.json file in databases also had ‘type’ instead of client. So I changed that to client, and the file in connections and it appears to have fixed it. Will report back if anything changes.