Property db doesn't exist on XataClient
With the code But when I try I get the error:
Property 'db' does not exist on type 'XataClient'
13 Replies
This is because when I made an initial query to create some data It returned the same error
Hello! Can you confirm if the path
../../xata
is the location of xata.ts (which defaults to src/xata.ts from the place where you do xata init
) ?
Just to provide an overview, when you run the CLI command xata init
which configures your current directory, that downloads the xata client module in node_modules and at the same time generates a file in the location src/xata.ts which contains your types, db details etc. This is the place you should get the xata client from, so we need to make sure that file corresponds to the path we're importing. This file extends the xata client node module with your own database specifics / types.
As a sidenote, if you make changes in the UI, for example create new tables or change the schema of an existing table, you would need to run xata codegen
to update your client file with the latest changes.The path
../../xata
is correct and finds the src/xata.ts file. I've ran xata codegen
again, which updated the tables array (with the new table that I created), but still I get the same errors
I even ran xata init --force
to re-init the project, which yet again didn't workI see. Which framework are you using? How are you running this ts code? (And it's on Windows right?)
I'm just using plain ts, and using nodemon currently to run the native typescript code (as it wont compile with that issue), and it is windows
Then it must have to do with the compiler configuration. Your code above works for me using nodemon 2.0.22 and tsc 4.7.4 (the Xata client is compatible with typescript 4.7+, just noting) with the defaults (no tsconfig file) but I was able to get the
Property 'db' does not exist on type 'XataClient'
using some module/target combinations. Can you paste your tsconfig.json?Thank you, we will take a look with the dev team for suggestions. To confirm, which version of typescript are you using?
5.0.4
Can you try "moduleResolution": "node" to see if it fixes the issue ?
The dev team identified an issue with the types export that may be impacting some libraries. We are working on it and will release an updated client version soon. I will let you know to try it out once it's available. In the meantime you can try setting module resolution to node to see if it helps.
Thanks, that worked.
Any update on this?
@PeanutDumplings The dev team has an improvement for the client which should fix the issue with NodeNext module resolution. It will be available with the upcoming release later this week, most likely around Wednesday!
Thanks :hapi: