Skip to content

test(knex): fix TAV tests for knex#5069

Merged
trentm merged 1 commit into
mainfrom
trentm-fix-knex-tav
May 12, 2026
Merged

test(knex): fix TAV tests for knex#5069
trentm merged 1 commit into
mainfrom
trentm-fix-knex-tav

Conversation

@trentm
Copy link
Copy Markdown
Member

@trentm trentm commented May 11, 2026

knex version 3.2.0 to 3.2.7 (inclusive) includes an "exports"
in package.json that broke deep-package imports. That was reverted
in 3.2.8, because apparently there are some use cases for knex
users doing deep package imports.

In our case, we were doing require('knex/package') in tests only
for getting the package version. While the "exports" existed there
was a mapping for "./package.json", so the workaround for us is simple.

Refs: knex/knex#6422


TAV tests for knex are failing on knex@3.2.7.
E.g. https://github.com/elastic/apm-agent-nodejs/actions/runs/25679762074/job/75392718232#step:3:307

node_tests-1  | -- installing ["knex@3.2.7"]
node_tests-1  | -- running test "node test/instrumentation/modules/pg/knex.test.js" with knex (env: {})
node_tests-1  | node:internal/modules/cjs/loader:657
node_tests-1  |       throw e;
node_tests-1  |       ^
node_tests-1  | 
node_tests-1  | Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package' is not defined by "exports" in /app/node_modules/knex/package.json
node_tests-1  |     at exportsNotFound (node:internal/modules/esm/resolve:314:10)
node_tests-1  |     at packageExportsResolve (node:internal/modules/esm/resolve:661:9)

Local repro:

npm run docker:start postgres
TAV=knex npx tav

knex version 3.2.0 to 3.2.7 (inclusive) includes an "exports"
in package.json that broke deep-package imports. That was reverted
in 3.2.8, because apparently there are some use cases for knex
users doing deep package imports.

In our case, we were doing `require('knex/package')` in tests only
for getting the package version. While the "exports" existed there
was a mapping for "./package.json", so the workaround for us is simple.
@trentm trentm self-assigned this May 11, 2026
@trentm trentm requested a review from a team as a code owner May 11, 2026 17:31
@github-actions
Copy link
Copy Markdown

🤖 GitHub comments

Just comment with:

  • run docs-build : Re-trigger the docs validation. (use unformatted text in the comment!)

Copy link
Copy Markdown
Member Author

@trentm trentm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/test tav knex

@trentm trentm merged commit b44014c into main May 12, 2026
41 of 43 checks passed
@trentm trentm deleted the trentm-fix-knex-tav branch May 12, 2026 16:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants