Error: Cannot find module './dialects/postgres' when upgrading Knex.js
0 reputation · 12 Nov 2020, 15:29 UTC
After upgrading Knex.js from a 0.x release to 1.x, the application fails to initialize because the internal dialect module cannot be located at the former path 'knex/lib/dialects/postgres'. The goal is to restore a working Knex instance by ensuring the resolver points to the new location 'knex/dialects/postgres' while preventing stale files from being loaded.
Additionally, there is no consensus on how Knex should handle .whereIn(column, []): some versions throw a validation error whereas others return an empty result set, and the documentation does not state the intended behavior. This ambiguity affects query reliability when empty arrays are passed inadvertently.
What steps should be taken to update the module path after upgrading Knex from 0.x to 1.x? How can developers verify that the dialect module resolves correctly after the upgrade? What is the expected behavior of .whereIn with an empty array in Knex?