ForkMeDaddy
ForkMeDaddy•13mo ago

Cannot find module '@/convex/_generated/api'

I try to call this query inside an API route (app router) and running npx run devgives me a typescript error. however my IDE shows nothing wrong and I can even jump to the definition. What is the problem?
No description
No description
17 Replies
erquhart
erquhart•13mo ago
Did it work before and recently stop? Any chance the @ alias was added since the last time it worked
ForkMeDaddy
ForkMeDaddyOP•13mo ago
I think so. but was a while because I was away for some time
erquhart
erquhart•13mo ago
Try without the @, use a relative path and see if that works
ForkMeDaddy
ForkMeDaddyOP•13mo ago
okay this seems better but gives me another error 😄
ForkMeDaddy
ForkMeDaddyOP•13mo ago
No description
erquhart
erquhart•13mo ago
Node dropped support for __dirname, can't remember in which release oh that's in your dependencies if that error is coming from convex, it's expecting a node environment
ballingt
ballingt•13mo ago
@ForkMeDaddy what's the syntax of your import without the @
ForkMeDaddy
ForkMeDaddyOP•13mo ago
No description
ballingt
ballingt•13mo ago
import looks ok, this is now a runtime error — yeah agree with @erquhart this looks like you're using a library that expects Node.js. Do you know what library is using ua-parser? or can you share the user.js file?
erquhart
erquhart•13mo ago
It looks like it's from next - if you can share your node version and version of next that'd be helpful too
ForkMeDaddy
ForkMeDaddyOP•13mo ago
okay so the user file imports something that needs to run in a node environment that is causing the error can I define a convex function that guarantees that?
ballingt
ballingt•13mo ago
Any actions defined in convex/* files that have "use node"; as the first line will be bundled to run in Node.js instead.
ForkMeDaddy
ForkMeDaddyOP•13mo ago
oh awesome I will try it thx. didn't know that
ballingt
ballingt•13mo ago
however a file is only bundled for one environment or the other, so you might need to refactor if you have stuff in users.js that needs run in teh normal Convex JavaScript runtime (like mutations and queries)
safal007
safal007•9mo ago
I am having same problem. Everything working fine but suddenly stopped working.
No description
ballingt
ballingt•9mo ago
@safal007 you might be able to fix by adding these prefix path aliases from your main project tsconfig.json to you convex folder tsconfig.json, but the fir sure fix us not to use path aliases like @/convex/... We'll look at linting to suggest this fix
safal007
safal007•9mo ago
Thanks @ballingt

Did you find this page helpful?