Cannot read property 'QueryBuilder' of undefined
See original GitHub issueCompiling and running a simple typescript example results in TypeError: Cannot read property 'QueryBuilder' of undefined
.
Environment
Knex version: 0.95.0 Node version: 14.16.0 Typescript version: 4.2.3
Steps to reproduce:
$ yarn init -y
$ yarn add typescript knex @types/node
$ tsc --init
Create a test.ts file with:
import {Knex} from 'knex'
console.log(Knex.QueryBuilder)
Then
$ tsc test.ts
$ node test.js
This yields the following error:
console.log(knex_1.Knex.QueryBuilder);
^
TypeError: Cannot read property 'QueryBuilder' of undefined
at Object.<anonymous> (/xxx/test.js:4:25)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47
The Knex
variable is not exported from the package, only knex
.
A simple fix could be to just add knex.Knex = knex
to knex.js ?
Issue Analytics
- State:
- Created 3 years ago
- Comments:12
Top Results From Across the Web
Cannot read properties of undefined (reading 'tablePivot ...
I'm trying to make a query builder with cubejs. I followed their documentation and copied the code of their sandbox here ...
Read more >TypeError: Cannot read property 'operator' of undefined #80
Hi,. When change the operator in material theme, throw "TypeError: Cannot read property 'operator' of undefined" . You can see demo material ...
Read more >Query Builder JavaScript error Uncaught TypeError
When I click on Export CSV I get this error in the console. I get this in Chrome and Edge. Firefox won't load...
Read more >typeorm cannot read properties of undefined
What happens in your case is typeorm is creating an instance of the entity and is not passing anything in the constructor. So...
Read more >Cannot read properties of undefined (reading 'id')
This error can be thrown for a lot of reasons, as it is not uncommon to look for the id property of an...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@gudleik 0.95.0 with the fix released!
That does sounds like a problem with our types. I’ll take a look tomorrow. Code itself should work, I think we just miss a type there.